Let's merge "issue1" with "master"

Current history

Use the merge command to merge branches.

$ git merge <commit>

By running the command above, the specified commit will be merged to the current active branch. Most of the time, you will want to merge a branch with the current active branch and you can do so by passing in the branch name in <commit>.

To merge commits into the master branch, let's now switch over to the master branch.

$ git checkout master
Switched to branch 'master'

Before merging, open myfile.txt and check the content of the file.

Git commands even a monkey can understand

As shown above, the change added on "issue1" described in the previous page isn't included in myfile.txt on master branch.

$ git merge issue1
Updating 1257027..b2b23c4
Fast-forward
myfile.txt | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

The position of the master branch will now move over to that of "issue1". A fast-forward merge has been executed here.

Current history

Now, let's confirm myfile.txt.

Git commands even a monkey can understand
add: Register a change in an index

Open myfile.txt and you will notice that the new line that we have committed to the "issue1" branch is now here on the master branch.