git revert should accept one commit, so the error complains that you give it a list of changes where it expects it. (Update: thanks to Jefromi for the fact that, since 1.7.2, git revert can actually accept multiple commits.) I suggest three possible ways to proceed below:
Create multiple return commits
I'm not sure that you can do this in one command, but if you know that db0bc is the last good commit (i.e. you want to return every commit after it), and the history will be linear, you can do
for s in $(git rev-list --reverse db0bc..) do git revert --no-edit $s done
Going back to the old state, but still on the same branch
On the other hand, if you just make sure that the story is there, you could always make the next commit with the state of the source tree back with the last good commit of db0bc without introducing return commits - you still have a story that was entered between you and yours new commit, but without a lot of retries between them. In addition, this will not have problems if the story is non-linear:
# Check that "git status" is clean: git status
Create a new branch for old commits
If you are the only person working on the project, or you have not yet clicked the wizard, or you know that resetting the main branch will not cause problems, you can use the alternative line and create a new branch in your current position, and then reset back, as described on github "undoing" page . In short, you can do:
# Make sure you're on master: git checkout master # Check that "git status" is clean, since later you'll be using "git reset --hard": git status
The diagrams on this github page make it nice and clear, I think.
Mark Longair Jan 17 '11 at 18:19 2011-01-17 18:19
source share