Recently I started a new project and I decided I wanted to try a new version control system. I have experience with multiple version control systems but have never played with git.
For those not familiar, from the git website, “Git is a free & open source, distributed version control system designed to handle everything from small to very large projects with speed and efficiency.” It was initially designed and developed by Linus Torvalds the creator or Linux.
Hear are a few things to consider with git.
- speed of operation
- not dependent on network access or a central server
- repository size is considerably smaller
- great web-based hosting sites like github.com
- Added complexity
- insufficient user interface tools
- higher learning curve when compared to svn
- version number are not sequential making it harder to walk through the history of the project.
So why did I decide on git? I had a small project that would be a perfect for my first open source project and with the online repository github.com I could host it online for free. While I don’t have any plans on working with a large group or any group for that matter, I am interested in future code reviews, branching and other benefits that source control can provide.
Adding a git repository to a project is incredibly easy:
$ git init
With git there is no central repository. Every user gets a complete project history locally. This increases the flexiblity and changes are copied from one users repository to another. Unlike svn you don’t necessarily have the most complete version of the project. This can add a layer of complexity to your projects versioning system.
After you have a local repository setup you can add changes to staging. In Git, you have to add your changes to the stage before committing them. I can stage my changes with the $ git add . command. This will stage all uncommitted and modified files. After committing, $ git commit, I can push it to my online repository on github with these commands.
$ git remote add MyProject firstname.lastname@example.org:njhamann/MyProject.git
$ git push MyProject master
With that in place my code is now hosted in a central location. Since it is a public repository you can fork the project and add, edit or completely redo the project. You can check out my public repository on github at https://github.com/njhamann/. If you’re interested in trying out git check out their great reference site at http://gitref.org/.