Monday 16 May 2011

Getting to grips with Git

Git is a world apart from Team Foundaation Server and people seem to be frightened at a first attempts with it, as it can seem complex. Stick with it though and you'll soon see past that and how simple it can be. Git is a distributed source control system, so it allows you to work disconnected from the main repository and still commit. This 'commit' is to your local repository. You should commit often. Once happy that all your tests pass should you push to the remote repository.
  1. clone - get the source code from your remote git repository
  2. Make your changes
  3. commit - commits your changes LOCALLY (not the remote git repository)
  4. push - commits your changes to the REMOTE repository
For me, working disconnected is the number one advantage for Git over TFS. Number 2 is the ability to create branches. Essentially just a seperate work stream you can use for working on seperate features. Once happy, you then merge your branch into the master branch (which is the main repository).
  1. clone - get the source code from the remote git repository
  2. branch branch-name - create a branch branch-name
  3. Make your changes on your branch
  4. commit - commits your changes LOCALLY (not the remote git repository)
  5. push origin branch-name - commits your changes to the REMOTE repository
  6. checkout master - switch to the master branch
  7. merge branch-name - merge the feature branch into the master
  8. commit and push !!!
I'd strongly recommend that you use the git bash until you get to grips with the git comands, then you can make use of the helper tools.
At the moment I'm still working with the bash but I occasionally use TortoiseGit for windows explorer integration and Git Source Control Provider for Visual Studio GUI integration.

No comments:

Post a Comment