Git: Decentralising version control
I’ve been a user of Subversion for a number of years, I was a little apprehensive about moving to a completely different versioning system but now I’m seriously glad I made the move. To recap, Subversion is a centralised version control system. What this means is that you have a centralised code repository, developers use clients to checkout code which they can work on until they’re ready to commit their work back to the main repository.
So what is Git and why move to it at all? Why reinvent the wheel?
What is Git
Git is a decentralised version control system. Clients can clone the repository from any other copy of the repository. In general you all still have a main repository you use as a focal point of committing but you can create your own branches and therefore have more control of your own repository structure (until you need to commit and merge of course). So instead of checking out and committing you clone the repository, commit your changes to your own local repository then push the changes back to the focal repository when you’re ready, merging if and when necessary.
Advantages
- No internet connectivity required – each client has a full copy of it’s own repository
- Distributed development – as mentioned every client has it’s own repository copy
- Strong support for branching / merging – distributed versioning systems lend themselves heavily to branching and merging often because every repository can at some point be considered a branch of others
- Handles large projects efficiently – Git is an order of magnitude faster than other versioning systems
- Ideal for feature development – users can branch themselves and work privately on their own feature independently of others
- Allows for very flexible development – developers can choose who’s repository they want to merge with at any point in time
Disadvantages
- Working in the same code area on similar features is trickier because merging may result in lots of conflicts
- Distributed development tends to encourage private work which is bad for development practices
- Maintenance work tends to be sloppier on distributed systems
Which should I choose
Ultimately it’s a personal decision. Many claim that a centralised versioning systems cannot work with distributed development, however, this is wrong. In a centralised versioning system if all developers worked on their own personal branch effectively you would have something similar to a distributed environment. In both systems you will still have eventually merge with someone responsible for releases, otherwise you have chaos and unpredictable builds, timelines and feature progress becomes difficult to track.
The nice thing I like about Git is just how easy it is to setup and get started in comparison with Subversion. No messing about plus hosting like Github makes things even easier.
Using Git on Github
Here’s just a few useful tips to get you started:
- Initialise Git repository in current folder
- Configure local Git to point to Github account
- Add link to the remote github repository as origin i.e. main repo
- Set the default branch to merge to as the origin – this allows a simple git pull without branch
- Pull the code from the remote repository i.e. origin
- Add a new file using the client
- Commit changes to your local repository
- Configure your buffer to 500mb so you don’t have issues with the size of commits
- Push the code to the origin
git init
git config --global user.name "Firstname Lastname"
git config --global user.email "your_email@youremail.com"
git config --global github.user username
git config --global github.token 0123456789yourf0123456789token
git remote add origin http://username@github.com/username/myrepo.git
[branch "master"]
remote = origin
merge = refs/heads/master
git pull
git add myfile.ext
git commit -am "Added myfile.ext to repository"
git config http.postBuffer 524288000
git push
In Summary
I hope this article has provided you with at least some insight into what Git is and in what way it varies from Subversion. Also, a precis on the advantages and disadvantages of each approach. If you agree or disagree feel free to leave me a comment below.
Popularity: unranked [?]






