Jamie ReardonTreehouse Project Reviewer
git checkout branch before merging?
In the video, the teach was checking out the two branches (master and testing) before merging the contents of the each with the command: git merge testing (for checked out master branch) and git merge master (for checked out testing branch).
So my question is, is this necessary to perform the checkouts before merging? Couldn't you also stay in a different checked out branch e.g. git checkout fix-nils and then run the command git merge master testing / git merge testing master to get the same desired results?
Liam ClarkeTreehouse Moderator 19,701 Points
I believe this video is showing you how to merge two local branches.
In this case you do need to checkout the receiving branch to ensure the HEAD is pointing to the correct merge-receiving branch.
This is needed because a working copy is needed to compare against to fix any potential conflicts when git is trying to find a common base commit between the two branches.
The example you give will actually merge branches master and testing on top of the current branch. Making a 3-way merge (octopus merge)
git merge master testing