Home > other >  how to undo git merge with remote origin master?
how to undo git merge with remote origin master?

Time:09-16

I am very bad situation due to a mistake.

I cloned master branch of remote private github repo, created my own branch a while ago.

I started doing edits, created a github pull request from within Jetbrain IDE a while back which was fine.

Today after making more changes in my code, I wanted to commit my changes to github earlier pull request so that the team can see my new changes. By mistake I merged my changes with remote master branch. The remote master branch show my changes which also has commit number that looks like 4f56ec45. I want to undo this commit.

I followed jetbrain online docs but it ended reverting my local changes, my IDE shows with my changes gone which is not what I want. The remote merge with master is still there.

Please help me how do I undo remote merge with master as if it never happened or at least it should undo all my changes to remote master.

CodePudding user response:

Either revert the commit or create a new commit that undoes your changes.

Ideally you get in touch with the repository maintainer and let him deal with it. If they allow anyone to push into their repository they should probably deal with the consequences. Plus they can resolve it in the way they prefer.

CodePudding user response:

You should force rewrite history of master branch

  1. git rebase -i 4f56ec45~
  2. change "pick 4f56ec45" to "drop 4f56ec45"
  3. git push -f origin master

This is common case. But you really should contact with teamlead and explain this situation. Rewriting history is not always a convenient approach especially when using 3-way merging.

  • Related