by BehindJava
What is Git Merge
In this tutorial, we are going to learn about git merge in detail.
What Is Git Merge?
Git merge is a command that allows you to merge branches from Git. Merging is a common practice for developers. Whether branches are created for testing, bug fixes, or other reasons, merging commits changes to another branch. It takes the contents of a source branch and integrates it with a target branch.
Git Merging
Merging of branches is done based on the time stamp of the commits.
-
Create a few commits on master.
touch f1 git add . git commit -m "a" touch f2 git add . git commit -m "b"
-
Check the commit history.
git log --oneline
-
Create a branch and create few commits on it.
git checkout -b test touch f3 git add . git commit -m "c" touch f4 git add . git commit -m "d
-
Check the commit history.
git log --oneline
-
Move to master and create few more commits.
git checkout master touch f5 git add . git commit -m "e" touch f6 git add . git commit -m "f"
-
Check the commit history.
git log --oneline
-
To merge the test with master.
git merge test
-
Check the commit history.
git log --oneline