Difference between revisions of "Git"

From Blue-IT.org Wiki

(HowTo git)
 
(29 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
== HowTo git ==
 +
 +
* '''Git Online Help: https://help.github.com'''
 +
* PRO GIT BOOK: https://progit.org
 +
* Scott Chaco's (Pro git book) Introduction:  https://www.youtube.com/watch?v=ZDR433b0HJY
 +
* SVN basic commands to Git commands  (CERN): http://aliceinfo.cern.ch/Offline/node/2912/#Commands
 +
* Git best practices (Rereira, CERN): http://cds.cern.ch/record/1644783
 +
 +
=== Practice ===
 +
* Local credential storage:  https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage
 +
git config --global credential.helper 'store --file ~/.git-credentials'
 +
 +
=== Troubleshooting ===
 +
==== Bare Repo ====
 +
Since git 1.7.0, if you like to create a server repo you have to use a so called "bare repo". This is a directory which contains NO worktree. For convention, you better name this director like "my_repo'''.git'''". The ".git" postfix should indicate this is a "bare repo".
 +
 +
On the server:
 +
mkdir my_repo.git
 +
git init --bare my_repo.git
 +
git update-server-info
 +
 +
On the client
 +
# point origin to the server URL
 +
git remote add origin user@server:/path/to/my_repo.git
 +
# OR, if the origin was somewhere else
 +
git remote set-url origin user@server:/path/to/my_repo.git
 +
 +
# push everything to the server
 +
git push origin master
 +
 +
You might also want to convert a given repo into a bare one:
 +
* Convert a repo into a bare one: http://stackoverflow.com/questions/2199897/how-to-convert-a-normal-git-repository-to-a-bare-one/2200662#2200662
 +
 +
Further reading:
 +
 +
* See Getting Git on a Server: http://git-scm.com/book/en/v2/Git-on-the-Server-Getting-Git-on-a-Server#_git_on_the_server
 +
* See What is a bare git repository?: www.saintsjd.com/2011/01/what-is-a-bare-git-repository/
 +
 +
== HowTo gitolite ==
 +
'''[UPDATE] --[[User:Apos|Apos]] ([[User talk:Apos|talk]]) 16:12, 4 November 2015 (CET)'''
 +
 +
Due to the fact I completely do not use the gui interfaces for git any more, I simple recommend using plain commandline git including secured ssh (string password, fail2ban, and / or rsa key usage ;-) On the server simply use [[#Bare_Repo|a bare git repo]]. If someone really needs this for production usage or like within a company, you should get a commerial account with [http://www.gitlab.com gitlab] or any other service.
 +
 +
This article about gitolite therefore is not maintained any more.
 +
----
 +
 +
There are different ways to install git, [[#Gitolite|gitolite]], and webacces (e.g. [[#GitlabHQ|gitlabhq])] on Debian oder Ubuntu.
 +
 +
In any case: be sure to read [http://sitaramc.github.com/gitolite the complete (!) gitolite documentation] before you proceed.
 +
This article is mainly for Debian squeeze (6.0) server.
 +
 +
Mainly this boils down to:
 +
# should use [[#Gitolite|gitolite]] anyway
 +
# which username you like to use by default to access the server: git, gitolite, whatever
 +
# which port to use for ssh
 +
# create a public or private repo
 +
# have http access via smarthttp or [[#GitlabHQ|gitlabhq]]
 +
# install it manually or the "debian way" (apt-get), however the latter will give you automatic security updates
 +
 +
=== References ===
 +
* [http://blog.muehlbachler.org/2012/01/how-to-install-a-private-debian-git-server-using-gitolite-and-gitlabhq/ How-To: Install a private Debian git server using gitolite and GitLabHQ]
 +
* [http://blogs.gentoo.org/tampakrap/gitolite-installation-with-gitweb-and-anongit-in-gentoo-and-debian/ Gitolite installation with gitweb and anongit in Gentoo and Debian]
 +
 +
== GitlabHQ ==
 +
Fast, secure and stable solution based on Ruby on Rails & Gitolite.
 +
* [http://gitlabhq.com gitlabhq.com]
 +
 
== Gitolite ==
 
== Gitolite ==
 +
Gitolite is the new framework around git. Easy project and user rights management.
 +
 
Everything well documented online:
 
Everything well documented online:
 
* [http://sitaramc.github.com/gitolite/ Entry point for the answer to most questions]
 
* [http://sitaramc.github.com/gitolite/ Entry point for the answer to most questions]
 +
 +
=== Troubleshooting ===
 +
==== User git ====
 +
After an uninstallation the user ''git'' remains on the system.
 +
 +
I had some problems (re)creating a user on my debian system (squeeze). I reverted (uninstalled) a gitolite installation and deleted the user ''git'' with
 +
userdel -rf git
 +
 +
After that I had to recreate a new user ''git'' with:
 +
useradd -d /home/git -b /home/git -m -s /bin/bash git
 +
passwd git
 +
 +
If you not do this, there is not valid shell, the  userdir in /home is not created and there is no password!
  
 
== Gitosis ==
 
== Gitosis ==
 
Is not activly maintained and developed any more. Use [[#Gitolite|gitolite]] instead.
 
Is not activly maintained and developed any more. Use [[#Gitolite|gitolite]] instead.
 +
 +
== Troubleshooting ==
 +
git pull
 +
fatal: unable to access 'https://github.com/somewhere/':
 +
    Failed to connect to github.com port 443: Connection timed out
 +
 +
Disable the firewall.
 +
 +
Edit the local git configuration:
 +
git config --global --edit
 +
 +
Trace the problem:
 +
GIT_TRACE=1 git pull
 +
 +
Possible solutions:
 +
git config --global url."https://".insteadOf git://
 +
git config --global --unset http.proxy
 +
export GIT_SSL_NO_VERIFY=1
 +
git config --global http.sslverify false
 +
 +
git config --global http.sslverify true
 +
git config --global http.sslCAPath /usr/local/share/ca-certificates/cacert.org
 +
 +
See:
 +
* GIT: http://stackoverflow.com/questions/21544803/git-bower-errors-exit-code-128-failed-connect
 +
* PROXY: http://stackoverflow.com/questions/3512202/github-https-access
 +
* SSL/CA: https://github.com/gitlabhq/gitlabhq/issues/4272
 +
 +
[[Category:Version Control]]
 +
[[Category:Project Management]]

Latest revision as of 21:13, 14 May 2017

HowTo git

Practice

git config --global credential.helper 'store --file ~/.git-credentials'

Troubleshooting

Bare Repo

Since git 1.7.0, if you like to create a server repo you have to use a so called "bare repo". This is a directory which contains NO worktree. For convention, you better name this director like "my_repo.git". The ".git" postfix should indicate this is a "bare repo".

On the server:

mkdir my_repo.git
git init --bare my_repo.git
git update-server-info

On the client

# point origin to the server URL
git remote add origin user@server:/path/to/my_repo.git
# OR, if the origin was somewhere else
git remote set-url origin user@server:/path/to/my_repo.git
# push everything to the server
git push origin master

You might also want to convert a given repo into a bare one:

Further reading:

HowTo gitolite

[UPDATE] --Apos (talk) 16:12, 4 November 2015 (CET)

Due to the fact I completely do not use the gui interfaces for git any more, I simple recommend using plain commandline git including secured ssh (string password, fail2ban, and / or rsa key usage ;-) On the server simply use a bare git repo. If someone really needs this for production usage or like within a company, you should get a commerial account with gitlab or any other service.

This article about gitolite therefore is not maintained any more.


There are different ways to install git, gitolite, and webacces (e.g. [[#GitlabHQ|gitlabhq])] on Debian oder Ubuntu.

In any case: be sure to read the complete (!) gitolite documentation before you proceed. This article is mainly for Debian squeeze (6.0) server.

Mainly this boils down to:

  1. should use gitolite anyway
  2. which username you like to use by default to access the server: git, gitolite, whatever
  3. which port to use for ssh
  4. create a public or private repo
  5. have http access via smarthttp or gitlabhq
  6. install it manually or the "debian way" (apt-get), however the latter will give you automatic security updates

References

GitlabHQ

Fast, secure and stable solution based on Ruby on Rails & Gitolite.

Gitolite

Gitolite is the new framework around git. Easy project and user rights management.

Everything well documented online:

Troubleshooting

User git

After an uninstallation the user git remains on the system.

I had some problems (re)creating a user on my debian system (squeeze). I reverted (uninstalled) a gitolite installation and deleted the user git with

userdel -rf git

After that I had to recreate a new user git with:

useradd -d /home/git -b /home/git -m -s /bin/bash git
passwd git

If you not do this, there is not valid shell, the userdir in /home is not created and there is no password!

Gitosis

Is not activly maintained and developed any more. Use gitolite instead.

Troubleshooting

git pull
fatal: unable to access 'https://github.com/somewhere/': 
   Failed to connect to github.com port 443: Connection timed out

Disable the firewall.

Edit the local git configuration:

git config --global --edit

Trace the problem:

GIT_TRACE=1 git pull

Possible solutions:

git config --global url."https://".insteadOf git://
git config --global --unset http.proxy
export GIT_SSL_NO_VERIFY=1
git config --global http.sslverify false
git config --global http.sslverify true
git config --global http.sslCAPath /usr/local/share/ca-certificates/cacert.org

See: