deloubast
If you want to team work with anybody using Git, then best is to setup your own public repository. This is how to do it.
Currently, on our server, we have made a /var/gitusers that is aliased to http://git.gplhost.com/users but you can set that up anywhere. For maximum security, best is to use the same unix username on both your server and your workstation/laptop, and then do chown my-username:www-data /var/gitusers/my-username and chmod 750 /var/gitusers/my-username before uploading anything.
If you need, we can give you a shell account on our git.gplhost.com server for your public repository (our policy is to give it only after you send the first patch file, so we know you can send valuable work).
Ok, let's start!
0. Prepare your name and email address
If you haven't done so before, please create a file ~/.gitconfig and include at least the following infomation:
[user]
name = Your Full Name
email = your@mail.address
By doing so, the contribution information in the git repository are more meaningful. This will also be the name that is displayed e.g. in the shortlog of the git summary as in http://git.gplhost.com/gitweb/?p=dtc.git;a=summary.
1. Create an archive to send to the server
Let's say you are working on the dtc-xen project, and have a dtc-xen folder already cloned with:
zigo@laptop:~/sources$ git clone http://git.gplhost.com/dtc-xen.git
Then you need to type:
zigo@laptop:~/sources$ git clone --bare dtc-xen dtc-xen.git
zigo@laptop:~/sources$ tar -cvzf dtc-xen.git.tar.gz dtc-xen.git
Note that if the archive is big, it's because it's including all the history of changes. For example, the dtc project archive file was more than 14 MB big when I tried to do that.
Then, you should upload the file to the web server you are using for your public Git repository:
2. Install the archive on the web server
zigo@webserver:/var/gitusers/zigo$ tar -xvzf /home/zigo/dtc-xen.git.tar.gz
and then inform git that it's now your public repository, and not your working one:
zigo@webserver:/var/gitusers/zigo/dtc-xen.git$ git --bare update-server-info
zigo@webserver:/var/gitusers/zigo/dtc-xen.git$ chmod +x hooks/post-update
3. Fixup your local repository so it knows about the public one
Back on your working repository, you can edit the .git/remotes/public file to make it know about your public repository.
zigo@laptop:~/sources/dtc-xen$ echo "URL: ssh://git.gplhost.com/var/gitusers/zigo/dtc-xen.git
Push: master" >.git/remotes/public
with of course /var/gitusers/zigo/dtc-xen.git being the path to your online public repository in the hard drive of your server.
That's about it! Now the only thing you need to do to publish your changes, is this:
zigo@laptop:~/sources/dtc-xen$ git commit -a
zigo@laptop:~/sources/dtc-xen$ git push public
and your modifications will be uploaded to your git public repository over ssh, using the nice Git CRC.
4. How to make a diff between 2 repo
Once you have setup your repository, somebody will be able to make a diff with the following commands:
git fetch http://www.example.com/dtc-xen.git
git diff -u HEAD origin --
You can use other interesting commands with your repository, like git-format-patch, to format your commits so that they can be sent via e-mail and revised by others.