Member-only story
Overview of the most frequently used Git commands, Part II: Branches
Merge conflicts in Git are very annoying, especially when they’re caused by some little detail no human on the team cares about. Having individual members or pairs of the team working on their own branches can help avoid or even prevent merge conflicts.
All Git repositories have a principal branch. Usually this principal branch is called “main,” but in older repositories it was called “master” and that was the only possible name for it.
In Part I of this series, I went over commands that can be used in the principal branch. Those commands can be used on other branches, though I did not cover any of the commands for creating and switching between branches. That’s what this part is about.
If you’re working on a project by yourself, it makes sense to do all the work on the principal branch.
It is also possible for a group of people to all work on the principal branch of the same repository without having any merge conflicts. But that requires a lot of coordination and discipline.
The idea of branches is that each individual or pair of a group has their own branch. Then, when an individual or pair are ready to integrate their work into the main branch, they make a pull request, preferably one to be reviewed by a different member or…