A Git Branch Changes Nothing

I'm serious. If you create a new branch in git, you didn't really do much of anything. All you did was make a pointer. There is no copying of the files. No additional changesets. When you checkout the branch you just created, you still didn't really do anything. It just changes which branch you’re on. The files don’t change at all. That's because git does not need to change the source code at all in order to deal with this new branch.

When you start changing the code, however, you'll be adding new commits that are in that branch. The branch itself isn't really a thing though, since git effectively just makes a linked list of your changesets.


In the example shown here, notice that the blue line for “feature-xyz” does not have a dot until it’s first commit. That is because the branch starts, and it’s just a link pointing nowhere. Once there is a commit, there is some significance, but the branch itself is nothing. Git is primarily just a tree made of these links. This simple example illustrates some basic branching and merging.

I hope this little bit of info about git makes using it easier. If you want to learn more about using GitHub, please check out my Pluralsight course on GitHub.