1

I've created a new GitHub PR for branch new-feature, it has 10 commits.

I want to revert it to be at the 5th commit.

What is the proper workflow?

Notes:

If I'm on new-feature and use git reset --hard <sha-of-my-5th-commit>, this will just move my local state back. I'm not sure how to affect github's history with this

Don P
  • 49,839
  • 95
  • 259
  • 394
  • Have you used `cherry-pick`? It allows you to pick certain commits and apply them to your branch. – Tumen_t Feb 14 '17 at 22:08
  • Here is an example of that. http://stackoverflow.com/questions/20698614/multiple-commits-cherry-picking – Tumen_t Feb 14 '17 at 22:10

2 Answers2

0

Please be careful with hard resets and push force. You should back up stuff before resetting. But,

After git reset --hard <sha-of-my-5th-commit> you can run

git push -f

to overwrite the remote branch.

Harald Nordgren
  • 9,512
  • 5
  • 33
  • 57
0

If you want to actually record the history after a reset with a differentiating commit or if force push is disabled, use the following commands:

After git reset --hard <sha-of-my-5th-commit>:

  git reset --soft FETCH_HEAD
  git commit -m "describe the changes you reset"
  git push
Daniel Leach
  • 2,909
  • 2
  • 12
  • 32