availability: September 2013
| Repository | Pro | Con | Controlling Access | Create Repositories |
|---|---|---|---|---|
| File share | No network access required | Not internet friendly | Using filepermissions | Needs preparation per project on the share |
| Git daemon | Fast git protocol | Not internet friendly port | no good permission control. Read by default, Write can be enabled , but only anonymous | per project needs to be blessed |
| Plain SSH server | Allows good security | Not internet friendly port, requires account creation per user on server | Uses filepermissions | per project inited |
| SSH server git-shell | Enhancement of Plain SSH Server scenario | Not internet friendly port, requires account creation per user on server | Uses filepermissions | per project inited |
| Gitosis | Adds good remote management of users and repositories, only requires one system account | Not internet friendly port | Uses gitosis-config file | No server initalisation, only config is needed |
| Apache http | Falls back to standard apache config, only requires one system account, internet friendly | Slightly overhead | Uses htpasswd | per project inited |
| Apache http + gitweb | Falls back to standard apache config, only requires one system account, internet friendly, adds nice view of repository | Slightly overhead, read-only access | Uses htpasswd | per project inited |
| github | Internet accessible, easy to use webinterface | Hosted externally | Managing sshkeys | Web interface |
$ cd $HOME/project-X
# git init enables the git repository $ git init
# You add the readme file to the repository $ git add README
# You commit your changed to your local repository $ git commit -a -m 'Added README'
# First we navigate to the repository place and will create a new project-X dir $ cd /share/git $ mkdir project-X $ cd project-X
# now we initialize this directory # but instead of using git init, we use git --bare init # "A short aside about what git means by bare: A default git repository assumes that you will be using it as your working directory, # so git stores the actual bare repository files in a .git directory alongside all the project files. Remote repositories don't need # copies of the files on the filesystem unlike working copies, all they need are the deltas and binary what-nots of the repository itself. This is what "bare" means to git. Just the repository itself." $ git --bare init
# First go to your local repository $ cd $HOME/project-X # Then make the link to the shared repository $ git remote add origin file:///share/git/project-X
# We push to the remote repository $ git push origin master
# Another user can now clone the repository using: $ git clone file:///share/git/project-X # Change something $ .... # Commit the changes $ git commit -a # Push the changes to the central repository $ git push
$ sudo yum install git-daemonMore detail can be found http://www.kernel.org/pub/software/scm/git/docs/git-daemon.html
# Start the git daemon $ git daemonThis creates a network listener on the GIT port. It allows by default read access to git projects.
# On the local side $ git push git://localhost/... Initialized empty Git repository in .... localhost[0: ::1]: errno=Connection refused localhost[0: fe80::1]: errno=Connection refused fatal: The remote end hung up unexpectedly
# On the git daemon side Error on daemon side: [9027] 'receive-pack': service not enabled for git://localhost/... ..
$ git clone git:localhost/your-path/project-X
# On the SSH server we assume var/git as the central repository place and will create a new project-X dir $ cd /var/git $ mkdir project-X $ cd project-X
# now we initialize this directory # but instead of using git init, we use git --bare init # "A short aside about what git means by bare: A default git repository assumes that you will be using it as your working directory # , so git stores the actual bare repository files in a .git directory alongside all the project files. Remote repositories don't need copies of the files on the filesystem unlike working copies, all they need are the deltas and binary what-nots of the repository itself. This is what "bare" means to git. Just the repository itself." $ git --bare init
# First go to your local repository $ cd $HOME/project-X # Then make the link to the shared repository $ git remote add origin ssh://user@gitserver/var/git/project-X
# We push to the remote repository $ git push origin master
# Another user can now clone the repository using: $ git clone file:///share/git/project-X # Change something $ .... # Commit the changes $ git commit -a # Push the changes to the central repository $ git push
# Start the git daemon $ git daemonThis creates a network listener on the GIT port. It allows by default read access to git projects.
# On the local side $ git push git://localhost/... Initialized empty Git repository in .... localhost[0: ::1]: errno=Connection refused localhost[0: fe80::1]: errno=Connection refused fatal: The remote end hung up unexpectedly
# On the git daemon side Error on daemon side: [9027] 'receive-pack': service not enabled for git://localhost/... ..
$ git clone git:localhost/your-path/project-X
# On the SSH server we assume var/git as the central repository place and will create a new project-X dir $ cd /var/git $ mkdir project-X $ cd project-X
# now we initialize this directory # but instead of using git init, we use git --bare init # "A short aside about what git means by bare: A default git repository assumes that you will be using it as your working directory # , so git stores the actual bare repository files in a .git directory alongside all the project files. Remote repositories don't need copies of the files on the filesystem unlike working copies, all they need are the deltas and binary what-nots of the repository itself. This is what "bare" means to git. Just the repository itself." $ git --bare init
# First go to your local repository $ cd $HOME/project-X # Then make the link to the shared repository $ git remote add origin ssh://user@gitserver/var/git/project-X
# We push to the remote repository $ git push origin master
# Another user can now clone the repository using: $ git clone ssh://user@gitserver/var/git/project-X # Change something $ .... # Commit the changes $ git commit -a # Push the changes to the central repository $ git push
fatal: What do you think I am? A shell?
# On Centos,Redhat to install gitosis $ sudo yum install gitosis
# This creates /var/lib/gitosis # This creates a user gitosis with as default homedir /var/lib/gitosis $ grep gitosis /etc/passwd gitosis:x:100:101:git repository hosting:/var/lib/gitosis:/bin/sh
.
|-- .gitosis.conf -
/var/lib/gitosis/repositories/gitosis-admin.git/gitosis.conf
|-- .ssh
| `-- authorized_keys
|-- gitosis
| `-- projects.list
`-- repositories
`-- gitosis-admin.git
|-- HEAD
|-- branches
|-- config
|-- description
|-- gitosis-export
| `-- keydir
| `-- myself@my-Portable.local.pub
|-- gitosis.conf
|-- hooks
| |-- applypatch-msg
| |-- commit-msg
| |-- post-commit
| |-- post-receive
| |-- post-update
| |-- pre-applypatch
| |-- pre-commit
| |-- pre-rebase
| |-- prepare-commit-msg
| `-- update
|-- index
|-- info
| `-- exclude
|-- objects
| |-- info
| `-- pack
| |-- pack-82e64648d14e24258fa7c569100c6805edfc314c.idx
| `-- pack-82e64648d14e24258fa7c569100c6805edfc314c.pack
`-- refs
|-- heads
| `-- master
`-- tags
15 directories, 23 files
$ sudo -H -u gitosis cat $HOME/.ssh/authorized_keys ### autogenerated by gitosis, DO NOT EDIT command="gitosis-serve myself@my-Portable.local",no-port-forwarding ,no-X11-forwarding,no-agent-forwarding,no-pty ssh-dss AAAAB3NzaC1kc3MAAACBAMAgxc ....
sudo chmod 755 /var/lib/gitosis/repositories/gitosis-admin.git/hooks/post-update
# Checkout the gitosis-admin repository (using the public key you used to gitosis-init $ mkdir gitosis $ git clone ssh://gitosis@gitosis-server:gitosis-admin.git # And two groups to the gitosis-conf [group project-X-read] members = usera, userb readable = project-XPushing your local repo to to the gitosis server
[group project-X-write] members = userc, userd writable = project-X
# Copy the public keys of usera,userb, userc, userd into the keydir, with the correct names |-- gitosis-export | `-- keydir | `-- myself@my-Portable.local.pub | usersa.pub | usersb.pub | usersc.pub | usersd.pub |-- gitosis.conf # Add the keys $ git add gitosis-export/keydir/*.pub $ git commit -a -m 'Added users' # push them back to the repository $ git push
$ cd project-X $ git remote add origin gitosis@gitosis-server:project-X.git $ git push origin master:refs/heads/masterThis will create a directory project-X under /var/lib/gitosis/repositories/
$ git clone gitosis@gitosis-server:project-X.git
# On the web server we assume var/git as the central repository place and will create a new project-X dir $ cd /var/git $ mkdir project-X $ cd project-XNow that we created the project directory we need to give apache access to it:
# now we initialize this directory # but instead of using git init, we use git --bare init # "A short aside about what git means by bare: A default git repository assumes that you will be using it as your working directory # , so git stores the actual bare repository files in a .git directory alongside all the project files. Remote repositories don't need copies of the files on the filesystem unlike working copies, all they need are the deltas and binary what-nots of the repository itself. This is what "bare" means to git. Just the repository itself." $ git --bare init
$ git clone http://git.yourdomain.com/project-X Initialized empty Git repository in /Users/mydir/project-X/.git/ fatal: http://git.yourdomain.com/project-X.git/info/refs not found: did you run git update-server-info on the server?Then you can need to run it manually the first time
$ cd /var/git/project-X $ sudo -u apache git update-server-info
<VirtualHost some-ip:80> Servername git.mydomain.com DocumentRoot /var/git <Directory "/var/git"> DAV On Options +Indexes +FollowSymLinks AllowOverride None Allow from all Order allow,deny </Directory> </VirtualHost>This will add a virtual server that has access to the /var/git directory using simple browsing.
<VirtualHost YOUR-IP:80> ServerName git.yourdomain.com DocumentRoot /var/git <Directory /var/git/> DAV On Options ExecCGI FollowSymLinks Indexes # Deny everyything here Deny from all AuthType Basic AuthName "git repository" AuthUserFile /var/git/htpasswd.git AuthGroupFile /var/git/htgroup.git </Directory>
<Directory /var/git/project-X> Allow from all Order allow,deny <Limit GET> Require group project-X-read </Limit> <Limit GET PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK> Require group project-X-write </Limit> </Directory> </VirtualHost>
$ cat $HOME/.netrc machine git.yourdomain.com login reader password readerNow you should be able to clone project-X
$ git clone http://git.mydomain.com/project-XPossible Errors
Trying update error: Cannot access URL http://git.yourdomain.com/project-X/, return code 22 error: failed to push some refs to 'http://git.yourdomain.com/project-X'If there's something wrong with the permissions. Maybe you don't have webdav enabled, the user is in the wrong group, or filepermissions are not set correctly. Check your apache error_log
$ git clone http://git.yourdomain.com/project-X $ git push fatal: git-push is not available for http/https repository when not compiled with USE_CURL_MULTIerror: failed to push some refs to 'http://git.yourdomain.com/project-X'Either you compile your git client with the correct curl options. Or you can alternatively mount the remote repository as webdav share and access it via file:// references. See http://wiki.dreamhost.com/Talk:Git
The following happens if your curl library was not compiled with the correct options to post to http://kerneltrap.org/mailarchive/git/2008/1/13/564431 After a bit of research it seems that CURL compilation into GIT was not entirely successful for the Git on Mac OS X. As I was already mounting the git repository via WebDAV you an push and pull to your locally mounted repository by replacing the http URL with the path to your mounted WebDAV (/Volumes//). This worked pretty well for me and works well with Dreamhost with very little configuration.
$ git push Fetching remote heads... refs/ refs/tags/ refs/heads/ No refs in common and none specified; doing nothing.
$ git push origin master
# Easy gitweb installation on Centos,Redhat, which installs itself in /var/www/git by default $ yum install gitweb # You have to manually create a /etc/gitweb.conf file $GIT= "/usr/bin/git"; $projectroot = "/var/git/";
<VirtualHost YOUR-IP:80> SetEnv GITWEB_CONFIG /etc/gitweb.conf ServerName git.yourdomain.com DocumentRoot /var/www/git AliasMatch ^(/.*?)(\.git)(/.*)? /var/git$1$3 <Directory /var/git/> DAV On Options ExecCGI FollowSymLinks Indexes # Deny everyything here Deny from all AuthType Basic AuthName "git repository" AuthUserFile /var/git/htpasswd.git AuthGroupFile /var/git/htgroup.git </Directory>
<Directory /var/git/project-X> Allow from all Order allow,deny <Limit GET> Require group project-X-read </Limit> <Limit GET PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK> Require group project-X-write </Limit> </Directory>
<Directory /var/www/git> Options ExecCGI FollowSymLinks Indexes Allow from all Order allow,deny AddHandler cgi-script cgi DirectoryIndex gitweb.cgi RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^.* /gitweb.cgi/$0 [L,PT] </Directory> </VirtualHost>
$ git clone http://git.yourdomain.com/project-X.git
$ git push No refs in common and none specified; doing nothing. Perhaps you should specify a branch such as 'master'. fatal: The remote end hung up unexpectedly error: failed to push some refs to 'file:///share/projects/project-X'If you have gone through the steps of git remote add origin ...., you might think that git would be smart enough to now that a git push needs to go to your origin.
$ git push origin masterAnother way to solve this is to add the following lines to your .git/config file
$ vi .git/config
[branch "master"]
remote = origin
merge = refs/heads/master
Or stil another way is to specify the option while you add the remote http://swedishcampground.com/adding-a-remote-to-existing-git-repo
$ git remote add --track master origin file:///share/projects/project-X