0

I made a mistake merging my last feature with develop; I had just to finish my feature and then do a PR, and then merge trought github.

What is the right method to go back to before I merge my last feature ?

enter image description here

I'm confused about when do 'git push', and really with a PR , I don't must use anymore git finish feature, not ? because this last merge, and I need to do PR to pass circle tests.

can I delete my remote branch (because i have a local with the same name)? before do push? that is better? in case of conflicts with the remote?

DDave
  • 1,400
  • 3
  • 16
  • 33
  • 1
    From GitHub, go to your PR and scroll down. There should be a "Revert" button. If you are working in collaboration with other users on the develop branch, it's the safer solution. – Tu.Ma. Nov 20 '18 at 10:35
  • but i had no PR; that is the problem.. I merged it directly, so need rollback to do a PR and not a finish feature that merge without pr – DDave Nov 20 '18 at 10:38
  • https://stackoverflow.com/questions/7099833/how-to-revert-a-merge-commit-thats-already-pushed-to-remote-branch – Tu.Ma. Nov 20 '18 at 10:41
  • thanks but? i use gitflow, so my branch is develop; i dont want to do mistakes with master – DDave Nov 20 '18 at 10:47
  • 2
    You should try and read through the answer. What you have to do is going in the develop branch and revert the commit. The revert will create a new commit that reverts all the changes. Now you have a clean deployment branch, and you can go back to your feature branch. – Tu.Ma. Nov 20 '18 at 10:58

1 Answers1

0

These are non-github solutions that can undo code changes from merge, which can be done in terminal(assuming you've checked out develop branch):

  1. git revert develop -m 2 and then git push.

    git revert develop -m 2: git revert means you're going to create a revert commit, and develop means your revert target is where your develop branch is pointing to, and -m 2 means you're reverting a merge commit and you intend to revert change from second parent of merge.

  2. git reset develop^1 --hard, and then git reset origin/develop --mixed, and then git commit(with messages like "Revert merge.")

    git reset develop^1 --hard means you're resetting HEAD & filesystem status to first parent of develop. So after this, your filesystem should not include changes from develop branch.

    git reset origin/develop --mixed means you're resetting HEAD into origin/develop, but preserve filesystem changes and add all into staged area. So after this, your filesystem should be exactly same to what it was before merge, and ready to commit.

ik1ne
  • 1,041
  • 15
  • 20
  • thanks but too late, i do a git reset --hard ae350e29e3d9aa194aa51f10befd677f0066f34f , and git push origin $(git_current_branch) -f , and now i've lost i think all the right develop branch, because ae350e29e3d9aa194aa51f10befd677f0066f34f it's a commit that i did not push ! git is really crazy – DDave Nov 20 '18 at 11:13
  • 1
    It’s because git doesn’t like removing changes. It’d much rather add additional commits which remove code. – evolutionxbox Nov 20 '18 at 11:41