Creating a new Branch
This Post is part of a series about Git, Git concepts, commands and usage patterns to remind me and to help me learn. The first post of the series is Git - A New Years Resolution.
When a new branch is created a new pointer is created that you can move around. For example, create a branch called testing branching from the tip of the master branch:
$ git checkout master
Switched to branch 'master'
$ git branch testing
This creates a new pointer to the same commit you’re currently on (in this case the tip of master).
How does Git know what branch you’re currently on? It keeps a special pointer called HEAD. In Git, HEAD is a pointer to the tip of the local branch you’re currently on. In the above, you’re still on master as the git branch command only created a new branch; it didn’t switch to that branch.
Last modified on 2018-01-11