Question

I goofed and committed development changes on the master, and pushed them upstream. Whats the best way to back out those changes from the remote repo, but keep a branch locally for later merging into master?

Was it helpful?

Solution

You just need to get your branches in order then do a forced push:

git checkout master        # though you're probably already there
# create the branch you should've committed to instead of master
git branch local-changes
# put master back where it belongs
git reset --hard <commit-master-should-be-at>
# and push it to origin!
git push -f

All the usual caveats about how this'll screw with anyone who's pulled from the upstream repo apply!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top