https://www.atlassian.com/git/tutorials/merging-vs-rebasing tells us merge
is always the safer solution, and rebase
is cleaner but has potential pitfalls.
This comes after a recent scare where I tried to rebase 100 commits and many things almost went haywire. Luckily I had the presence of mind to git rebase --abort
and use git merge
instead. Now, here I did a practical experiment in how it works: https://github.com/c6z3h/demo-rebase-vs-merge
Spent an hour or so creating branches, merging and the like, and it seems that bottomline is:
- write unit tests if have time (who am I kidding?) to avoid silent code addition / removal breaking existing features
- code review the
rebase
/merge
changes, specifically in files you know that you have amended in the local branch (for example you were working on search function, don't bother checking the homepage code change, just verify that your search pages' code is still valid) - (golden rule by Atlassian) only rebase onto a branch you know that only you are editing / relying on
Top comments (0)