Branch management

  • A branch is a parallel universe in a science fiction movie, where you are trying to learn Git while you are trying to learn SVN in another parallel universe.
  • If the two universes didn’t interfere with each other, it wouldn’t matter to you right now. At some point, though, the two parallel universes merged, and as a result, you learned both Git and SVN!

  • What does branching do in practice? Let’s say you want to develop a new feature, but it takes two weeks to complete. In the first week, you write 50% of the code. If you submit it immediately, the incomplete code base will cause others to be unable to work because the code is not finished. If you wait until all the code is written and then commit again, you run the risk of losing progress on a daily basis.
  • Now that we have branches, we don’t have to be afraid. You create a branch of your own, which no one else can see, and continue to work on the original branch, while you work on your own branch, commit as you like, until the development is finished, and then merge into the original branch once, so that it is safe and does not affect the work of others.
  • Other version control systems such as SVN have branch management, but once you use them you will find that they are intolerably slow at creating and switching branches. As a result, the branch function becomes obsolete and nobody uses it.
  • But Git branches are different. You can create, switch, and delete branches in less than a second! It doesn’t matter if your repository is 1 file or 10, 000 files.