tags:

views:

604

answers:

2

I have a remote git repository, and I need to roll back the last n commits into cold oblivion.

+5  A: 

You can use git revert for all the n commits, and then push as usual.

Or you can git reset --hard HEAD~n and "git push -f", but that is not good for shared repositories, as you will break others work based on your branch.

elmarco
I am glad it was clear enough :) thanks
elmarco
+2  A: 

elmarco is correct... his suggestion is the best for shared/public repositories (or, at least public branches). If it wasn't shared (or you're willing to disrupt others) you can also push a particular ref:


git push origin old_master:master

Or, if there's a particular commit SHA1 (say 1e4f99e in abbreviated form) you'd like to move back to:


git push origin 1e4f99e:master
Pat Notz
Great point about the SHA as a reference point!
robertpostill