So you are the happy admin or user of a shared Linux server. You know that Git is very cool, and you want to install what's necessary on the shared server to host user repositories there. You're like me: you've read some Git documentation, but you just haven't found some sort of executive summary comprehensively listing how to do that. I hope this place will help!
Normally, any server on which users may login and have a personal web space, and core git binaries are installed, is sufficient for publishing git repositories, without any server admin task involved; however, what's proposed here results in a more formal repositories handling on the shared server, allowing a global view of all hosted repositories and unified management, and more cool git repository URLs using the native git protocol.
$ urpmi git-core gitwebFor other distros:
$ mkdir /pub/git
our @git_base_url_list = qw(git://<shared-server-hostname> ssh://<shared-server-hostname>/pub/git);
$ cat > /etc/xinetd.d/git-daemon <<EOF
# description: The git server offers access to git repositories
service git
{
disable = no
type = UNLISTED
port = 9418
socket_type = stream
wait = no
user = nobody
server = /usr/bin/git-daemon
server_args = --inetd --export-all --base-path=/pub/git
log_on_failure += USERID
}
EOF
$ service xinetd restart
A user tells an admin he'd like to have a new repository created for him.
We suppose the data for the repositories will live in the user directories, using symlinks from the base project directory, so that repository data live within user quotas. In the following examples, you may wish to rather have files in the base project directory if no user quota is enforced/wanted.
# mkdir ~/gitrepos/<name> (directory name doesn't matter, but the wanted name
for the repository makes sense)
# cd ~/gitrepos/<name>
# git init
# touch foo
# git add foo
# git commit -m 'just an initial commit'
# mkdir ~/gitrepos/<name> # cd ~/gitrepos/<name> # git init # tar xvf <archive> # git add . # git commit -m 'initial import'
# cd <cvs-repo-checkout-dir> # git-cvsimport -C ~/gitrepos/<name>(it will even properly "merge" history of renamed files!)
# git-svn clone http://<svn-url> ~/gitrepos/<name> # rm -rf ~/gitrepos/<name>/.git/svn
$ ln -s /home/johndoe/gitrepos/<name>/.git /pub/git/<name>
# cd ~/dev
# git clone ssh://<shared-server-hostname>/pub/git/<name>
# cd <name>
hack...
# git add .. (if new files were added)
# git diff
# git commit
hack more...
# git commit
# git push (push commits into master repository on shared server)
# cd /tmp
# git clone git://<shared-server-hostname>/pub/git/<name>
# cd <name>
hack...
# git add .. (if new files were added)
# git diff
# git commit
hack more...
# git commit
# git pull (synchronize with master repository on shared server)
# git diff origin (view all the local changes to master repository)
# git format-patch origin (generate patches for email submission)
User reviews and selectively apply patches, and pushes into
master repository afterwards.
# git am -i <patchfile> # git push
Guillaume Cottenceau
Last modification: Tue Jun 10 10:06:26 2008