DEV Community

Discussion on: Oops, I just pushed a git commit to the wrong branch. What now?

Collapse
 
baukereg profile image
Bauke Regnerus

Force pushing is absolutely fine in case of personal feature branches.

Collapse
 
smeijer profile image
Stephan Meijer

No it's not. We also have this rule, and I so do it. But it's not "absolutely fine".

A reviewer might already have checked your branch before. And by changing your history, you remove the option for them to only review your latest changes.

The entire review must now be done all over.

Comments that were bound to a specific commit, are now gone as well.

Thread Thread
 
baukereg profile image
Bauke Regnerus • Edited

Agreed. That's why I said "personal" feature branch, before it's touched or reviewed by anybody else.

Then again, I don't mind a force push to prevent commits like "oops forgot semicolon". Commits like that are pollution and won't help anybody in the future trying to look back in history. I usually remove them when a pull request is ready to be merged.

Comments are temporary anyway and no replacement for documentation.

After all it's about knowing what your doing. I prefer communication/education over arbitrary rules in my team.