Git is a version control system, see http://git.com for more information. (:toc Index)
git is a version control system (like CVS) however it is a new system that is designed to be quite different from CVS.
The main differences with CVS are:
The advantages for pulsar astronomers is mainly that we tend to break our code very often. This means that often either we break the CVS version or are too scared to check into the CVS version in case we break it! With git, we can keep developing with version control, i.e. tracking changes and allowing us to roll-back or backup things, without having to risk breaking someone else’s code. Then when we are sure that it works, we can tell others to ‘pull’ from our public repository and they can choose if they want our changes.
The downside is that it is possible to have many versions of the same code. It seems however that many of us have our ‘own’ version of lots of code anyway.
You can create a new empty repository by changing to your development directory and typing
git init
This creates an empty repository. To add files to be tracked, for example:
git add ./src/ ./doc/
would add the contents of src and doc to the version control.
To see the current status of tracked/untracked and changed files:
git status
To commit those changes to your local repository do:
git commit -a
(the -a option tells it to commit all changes, otherwise you have to specify the files to commit). Then enter a commit message.
When you have files to be tracked by git, you always work with a ‘local’ repository. This is stored in .git in the root of your repository. If you want to use an existing repository, you must ‘clone’ the existing repository. You can clone repositories from the web, over ssh or from the local file system. e.g, to clone the pulsarhunter repository
git clone git://github.com/SixByNine/pulsarhunter.git
This copies all the files and also the version history from the cloned repository. If you want to update the project you can do a ‘pull’ from that repository, e.g.
git pull git://github.com/SixByNine/pulsarhunter.git master
master at the end tells it you want to pull the ‘master’ branch, that is the default branch. You can set aliases so you don’t have to remeber the long urls:
git remote add mkeith git://github.com/SixByNine/pulsarhunter.git
would create an alias called ‘mkeith’ that pointed to M.Keith’s repository. By default the repository you cloned is aliased as ‘origin’.
The git manual is fairly comprehensive. If you are familiar with CVS it may take some time to remeber the slightly different commands, but many are the same (e.g. ‘git diff’ is very similar to ‘cvs diff’).
If you want other people to easily be able to download your changes, you might want to set up a public repository, for example at http://github.com.
Once you have done this, create a new repository on the site, or if you are working with existing code ‘fork’ the project instead.
Add an alias for your project, e.g.:
git remote add public git@github.com:yourname/pulsarhunter.git
Then you can ‘push’ your changes to your public repository:
git push public master
Would send your ‘master’ branch to the public repository, for others to download.