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
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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.