Difference between git merge and rebase

The main reference of this article:


Two git merge commits are merge and rebase.
Both merge and rebase are functions used to synchronize the modified content on the remote branch to the local.

Let's talk about merge first.
The usage process is like this
edit file
git add .
git commit -m "remarks for this commit"
git fetch
git merge origin master
If there is a conflict to deal with the conflict, you need to use git add . git commit -m "handling conflict remarks" after dealing with the conflict
git push origin master

Process of using rebase
edit file
git add .
git commit -m "remarks for this commit"
git fetch
git rebase origin master
Will prompt whether there is a conflict, use git add . git commit ---amend after dealing with the conflict
git rebase --continue (if all are processed ok, then ok, otherwise continue to process conflicts)
git push origin master



It can be seen from the above process that a new commit is required every time the merge method is used, but not when rebase is performed. When rabase is used, only the previous commit needs to be reused.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325641203&siteId=291194637