Home > OS >  if you accidentally merged your branch with staging, will reverting it damage the history
if you accidentally merged your branch with staging, will reverting it damage the history

Time:05-04

i pushed a branch to the main, instead of staging, and then i reverted this change.

Has this left any lasting effects such as changed the history or are all negative effects removed?

CodePudding user response:

Has this left any lasting effects

Yes. A git revert of a merge commit changes the state but not the topology (history). Thus, although the main branch looks correct as to its current state, your branch's commits now cannot be merged into main ever again in future, because they are still part of main's history. That may or may not be a problem; it all depends.

(This is the problem so well discussed at https://github.com/git/git/blob/master/Documentation/howto/revert-a-faulty-merge.txt).

CodePudding user response:

Why not use git reset --hard <commit>?

It'll allow you to go back to the commit you want and erase any change you made after.

  •  Tags:  
  • git
  • Related