9

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 1

11

git checkout master
git branch newBranch
git reset shaToResetMasterTo

Sign up to request clarification or add additional context in comments.

6 Comments

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^..shaResettedTo
Not sure I am following you. Do you want both the newBranch and master to be at the same spot?
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.
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.
You should change last line to git reset --hard shaToResetMasterTo.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.