I would like to make a branch from master then revert master back to a certain point. How can this be achieved with git?
1 Answer
git checkout master
git branch newBranch
git reset shaToResetMasterTo
6 Comments
Chris Ledet
Now the remote repo is ahead by many commits. How can I push my reverted changes back? Is there a way to revert by range? like
git revert HEAD^..shaResettedToAndy
Not sure I am following you. Do you want both the
newBranch and master to be at the same spot?Chris Ledet
No, I want something like
git reset shaHere to make a commit to undo all the previous changes so master isn't behind on remote/master. Make sense? Something like git revert <sha> but that reverts one commit.Andy
Ahh, I misread your comment.
git push remote master if it is tracking the remote master, it will push remote/master to the correct spot.xyz
You should change last line to
git reset --hard shaToResetMasterTo. |