One of the features, that differentiates Git from other DSCM like Bazaar and non-distributed SCM like Subversion, is that it holds all of your branches within .git repository that’s in your working copy directory.
Some of devs consider it a disadvantage: you get main development line and all of the branches in one working copy; others as an advantage – since you get all the repository in one directory.
Subversion and Git
With Subversion you checkout, hack hack hack and commit. That’s fine. Now you need to create a branch so you can develop a feature without sacrificing changes on trunk. The workflow is pretty straightforward: branch within repo (fast), branch checkout (slow), hack hack hack and commit. But what’s hidden under hack hack hack?
A complete project rebuild at start. Why? Because you’ve just checked out a branch to a separate directory. If you have a smallish VS solution with a couple of projects – it doesn’t matter – but if you have a solution with 100+ projects… time to get a fresh cup of coffee!
Now the same with Git: create a branch (fast), branch checkout (fast), hack hack hack and commit. Simple as that. But since we have all the branches within our repo/working copy and checking out only swaps modified files and these are none on clean branch – what do you need to rebuild? Nothing. No changed files = no rebuild.
Of course one might use “switch” command of svn but it has several disadvantages:
- It’s slow; svn needs to check all the files on the remote repository since local copy has no information on branches
- It destroys all working copy modified files (correct me here if I’m wrong)
Bazaar and Git
Even though Bazaar is a DSCM you branch to separate directories. So cost of creating a new branch is as high as with Subversion: after branching you need to rebuild whole project. Moreover I don’t know if Bazaar supports “switch-ing” (as with Subversion) at all.
Of course this is an initial cost and after that if you want to switch within Visual Studio you either open new instance or load new solution.
With Git it’s much more comfortable: just checkout new branch and Visual Studio will detect and reload all open files that are modified. Simple and fast. You don’t even need to remember what files you were working on.
This feature of Git has also other advantages:
- Backup: you backup one directory and only one directory and it’s whole repo!
- Merge between branches: no separate directories need to be given/checked, just checkout to destination branch and merge the source branch.
- Easy on fingers: no cd-ing around if you use console
But all of this is pretty subjective as usual…