Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save viswanath11/04eb5f5ad63dde27498f67a1c4e71674 to your computer and use it in GitHub Desktop.
Save viswanath11/04eb5f5ad63dde27498f67a1c4e71674 to your computer and use it in GitHub Desktop.
Differences between git merge and git rebase

Merge IS:

• git merge apply all unique commits from branch A into branch B in one commit with final result • git merge doesn’t rewrite commit history, just adds one new commit

Rebase is:

• git rebase gets all unique commits from both branches and applies them one by one • git rebase rewrites commit history but doesn’t create extra commit for merging

Differences between git merge and git rebase

• git merge is a default behavior when you use git pull. Use it as default if you are not bothering about commit history and want to avoid problems • use git rebase to make your commit history more clear and consistent (use it only before pushing to remote servers to keep your name and karma clean) • use git rebase for temporary local branches — they are not necessary for public commit history and won’t make problems • use git rebase -i (interactive) for rewriting your local commit history into pretty one before pushing it on the remote server.

• The rebase just overwrites the history of the commits • the marge git merge doesn’t rewrite commit history, just adds one new commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment