I notice that no one is giving the "small" tutorial for GIT, so I'll try to cover it. GIT is faster and superior to SVN, but maybe it is easier for you to get an SVN account on a server at your university, since SVN is well established. Also may of your collaborators would know how to use it.
Even if you collaborate using SVN you may want to use GIT for your own local versioning (I do!).
First bit of warning: GIT is very powerful and for basic usage is only slightly harder to use than SVN (e.g., one option to be added in the command line; two steps commit for central repository).
Second bit of warning: GIT has the philosophy of considering a set of changes to be atomic (a $\Delta$ as they call it) even if the set spans several files. Also in GIT you have the notion of local repository and central repository.
GOOD: You can work offline.
BAD: You need two steps commit to a central server.
Basic commands assuming you already have a repository
- Clone a repository:
git clone <url>
- Update your local repository:
git pull <repo>
or just git pull
if you cloned as above.
- The pull command really does both
git fetch
and git merge
. The former "fetch" stuff from the central server, and the second apply a merge of your files and the ones of the server.
The merge is automatic as long there are no simultaneous edits on the same parts of some files. If the merge fails you working directory remains in a "merge state", which means that you have to fix the conflicts and then you have to commit the merged copy. If you still have unmanaged conflicts in you files then the commit would fail again, no garbage committed.
- Add a new file to be committed:
git add <file name>
.
- Commit changes to you local repository:
git commit -am "<textmessages>"
or git commit -a
if you want to edit the commit messages.
- Push the changes in your local repository to the central repository.
Notice that for pushing changes to your central repository you first have to commit to your local repository and the you have to push all the commits (even more than one) to your central repository.
Create a user-local repository
- Creation of a repository
git init
in any folder you like.
- Done!
Create a public-shared repo (also private if you pay cash) with a nice GUI.
Crate as many private/public repository with different groups of users but no GUI.
- Ask for an SSH account with no password on an accessible machine.
- Don't worry since authentication is done by SSH keys.
- Install Gitosis according to this tutorial.
- Now you can administrate you own git server by editing a single file and committing it to the repository!
Git does not need a central server: any folder in your computer can be used as repository, so you can play with git and make your tests offline. You can initialize one repository and simulate three collaborators in three other folders without sending one bit on the net. This is because any cloned copy of the repository is a full featured repository to which you can commit. This is good if you want to work in a flight between USA, China or Europe.