What is the difference between git merge and git rebase?
| git merge | git rebase |
|---|---|
| Joins two branches, usually with a merge commit | Moves your commits on top of another branch |
| Keeps the real history as it happened | Rewrites commits (new hashes) for a straight line |
| Safe on shared branches | Should not be used on pushed, shared commits |
| Conflicts are solved once | Conflicts may appear for each replayed commit |
A common rule: rebase your own local feature branch to update it, and merge when the branch goes back to main. See Git Merge and Git Rebase.
Learn more about the similar topics:
| Tutorials |
|---|
| Git Branch |
| Git Checkout and Switch |
| Git Merge |
| Git Merge Conflict |
| Git Rebase |
| Git Cherry Pick |
| Git Branching Strategy |