git is a distributed versioning & revisioning system. It can be used locally and remotely.
git automatically tracks all files that were changed and has the ability to synchronize the files to a remote server.
In order to use git, you need to have git installed on your computer, which is most likely the case if you're on a Mac or a Linux system. For all other cases, you can get git here: git-scm.com.
This page shows some common commands, but remember that most modern IDEs support versioning systems like git with an additional graphical user interface (in case of Xcode there's a code-timeline and built-in file merging capability).
With other revisioning systems, it can be quite a hassle to create an initial setup for a folder, with git this is really easy. Just open up your shell, change the directory to the directory you wish to use git and type:
cd myProjectPath git init
To add a remote git server, type:
git remote add origin ssh://myserver.com
For example, you can use github.com to host your open source projects, or bitbucket.org. You will find an excessive online help on how to setup a remote server on github: How-to-Setup github. Basically, you only need a private/public ssh key and a valid user account.
But remember, you can use git only on your local computer as well, it is not required to have an online server!
to get the status of your local git repository, query:
to add files you type:
git add myfile.ext
or to add all:
git add .
If you changed something and would like to store these changes as a version, you can "commit" your update:
git commit -a -m "comment about change"
At this point, your commit is only local! You can commit as few or as many changes as you like. But at the end of the day, you should push your changes to the server:
git push origin main
If you are interested in getting the changes from the server to your local machine, type:
That's all for the beginning!
Easy, isn't it?
Setting up a versioning repository has many advantages, these are just a few:
With a local git repository, you always have:
With an (additional) online repository, you can:
So: forget CVS and SVN, with GIT there's really no excuse to not use a versioning systems anymore. There is also bazaar, which claims to be even easier than GIT, but isn't as widely adopted. Mercurial is another version control system which is becoming more and more popular.
An (advanced) tutorial, mainly based on input commands to set up a project with a remote server.