The most concise usage of GIT merge

Time:2021-4-9

Git merge is a frequently used command in git, which is mainly used to add (merge) two or more development histories. This article brings you the common usage of GIT merge command.

There are three grammars of GIT merge


git merge [-n] [--stat] [--no-commit] [--squash] [--[no-]edit]
  [-s <strategy>] [-X <strategy-option>] [-S[<keyid>]]
  [--[no-]allow-unrelated-histories]
  [--[no-]rerere-autoupdate] [-m <msg>] [<commit>…?]
git merge --abort
git merge --continue

Usage of GIT merge

The GIT merge command is used to merge from the specified commit (s) to the current branch.

Note: the specified commit (s) here refers to the time from these historical commit nodes to the current separation.

1. It is used in Git pull to integrate changes in another code repository (i.e. git pull = git fetch + git merge)

2. Used for merging from one branch to another

Let’s look at the usage of GIT merge. The details are as follows:

1、 After the code on the development branch (DEV) reaches the online standard, it should be merged into the master branch


git checkout dev
git pull
git checkout master
git merge dev
git push -u origin master

2、 When the master code changes, you need to update the code on the dev branch


git checkout master 
git pull 
git checkout dev
git merge master 
git push -u origin dev

Here is the article about the most concise usage of GIT merge. For more information about the usage of GIT merge, please search previous articles of developer or continue to browse the following related articles. I hope you can support developer more in the future!