Git Merge Vs Rebase

When to use git merge ?

Use it as a default scenario when you don’t want to bother about the commit history and want to avoid problems, anyways it comes as default with git pull.

When to use git rebase ?


Use it to make your commit history look more clear and consistent.

Can be used for temporary local branches(like feature branches).

You can use git rebase -i(interactive) for rewriting the local commit histories into a neat one before you push it to the remote repository.

Difference between Merge and Rebase – When to use what


Git MergeGit Rebase
git merge apply all the unique commits from one branch to the other in one commitgit rebase takes all the unique commits from both the branches and applies them one by one
merge does not rewrite any commit history but just add one new onerebase rewrites the commit history but doesn’t create extra commit to merge

Summary

In this tutorial we looked into the difference between git merge and git rebase and when to use what.
Hope you liked it!


Leave a Comment