I am starting to like Git. Check out what it is here.
This is more like a note-to-myself kind of post, but also a crash introduction how to replace a shared CVS repository with Git.
Assume you have Git binaries installed and a directory full of files (maybe tracked with CVS, Subversion, some other version control tool, or not at all – it really doesn’t matter). Jump into the directory and type:
> git init .
Now you have a Git repository. You can do local commits, you can clone the repository with the ‘git clone’ -command, and so on. However, I want to have a central point, which is backed up, and which is a “hub” for the other repositories. An example is a “Documents” -directory, which I just want to:
a) store “the state” on a server,
b) sync between different machines,
c) store the history of changes,
d) store the checksum of each file,
e) be able to do simple ‘git push’ and ‘git pull’ without extra magic
Here is how to set it up (check out the command explanations from man pages if you care):
On the server, create a bare Git repository:
> mkdir ~/Documents.git
> cd ~/Documents.git
> git init --bare .
On a machine with the existing Documents directory:
> cd ~/Documents
> git init .
> git add *.txt
> git commit -m "Added all old .txt -files."
> git remote add server ssh://server/home/user/Documents.git
> git push server master
> git branch --track m2 server/master
> git checkout m2
> git branch -d master
> git branch -m m2 master
On all other machines, simply:
> git clone server ssh://server/home/user/Documents.git Documents
> cd Documents
> vim foo.txt
> git add foo.txt
> git commit -m "Edited foo.txt."
> git push
After these steps, you can just keep doing ‘git commit’, ‘git push’ and ‘git pull’ on all of the machines, and the “hub” at the server is easy to backup.