-1

I am a complete neophyte with git If it is in any way possible for someone to screw something up or not know it, assume that to be the case :-)

I added my changes, did a commit, and issued a 'git push origin' but forgot to append the branch. So git cheerfully pushed my work into the master. I tried a 'git revert', but that deleted my changes from my computer.

How do I get my work out of master and back on to my computer, and then revert master back to the way it was before?

John Oliver
  • 325
  • 2
  • 4
  • 11

1 Answers1

1

Start on master, and run a git pull so the remote and your local are in sync.

Checkout your feature branch, and run a git cherry-pick for the commits that you want.

Checkout master, and run a git reset --hard <commit-id> to the commit you wish to go back to.

Then you can do a git push --force on master to update the remote.

Peter Foti
  • 5,526
  • 6
  • 34
  • 47