Merges / Simple merging

git merge <branch>

The simplest and safest way to converge streams of work together. The commits from one branch are added into another using the diff of each file to decide how the files change.

The commit hashes and messages all remain the same after the merge has taken place - the commits are just ‘moved’ by moving where the branch reference is.

The default ‘strategy’ on the git command-line is a fast-forward merge. This takes the unseen commits from one branch, and overlays them on top of the other.

The default strategy in Gihub & BitBucket etc, is a non fast-forward merge. The difference can be seen here.

git merging diagram showing feature branches merging into develop in two ways

After this merge, the ref for HEAD, branch and develop will all point to the same commit.

$ git checkout develop
$ git merge branch

Next, we look at rebasing