DEV Community

Discussion on: Git Rebase for Preventing Merge Commits

Collapse
 
sir_wernich profile image
Wernich ️

rebasing my branch before creating a PR was my strategy for a long time, until i went through the "pro git" book:

_Do not rebase commits that exist outside your repository and that people may have based work on.

If you follow that guideline, you’ll be fine. If you don’t, people will hate you, and you’ll be scorned by friends and family._

from here

we have our main branch (development) and three of us decided to make a new branch (conversations) to work on messaging things. we then branched off of that and each did our own work, then made PRs to conversations. after a while, that branch had a couple commits, but development was also moving along. then we rebased conversations onto development, which cause our own local branches to be out of sync with conversations. the rebasing became a nightmare for us.

since then i've adopted the stragtegy of "if i haven't pushed this branch to remote, then it's ok to rebase".

ps: when i started there, i was new to git and i once spent an entire day rebasing because i worked for too long on my branch and ended up with lots of commits that needed to be rebased. finding out about interactive rebase and squashing was a game-changer. a lot less crying. :D