top | item 33615421

(no title)

mjsir911 | 3 years ago

Maybe I'm misunderstanding, but isn't this what `git revert` is for?

Harder with an amend due to having to get the difference of commits within the reflog, sure.

discuss

order

mikepurvis|3 years ago

git revert doesn't undo a commit though— it creates a new commit that undoes it. That might be what you want under some circumstances, but most of the time that I want to revert it's a commit I just made and haven't pushed yet, so I just want to pretend it never existed.

pooper|3 years ago

I don't know much about git but I just do

    git reset --soft HEAD~n 
where n is the number of commits I want to undo.

Known issue: can't undo all the commits.

still_grokking|3 years ago

What's wrong with just working on and when the changes finally look like they should just do a `git commit --amend`?

Or if the commit should for some strange reasons really never exist just move HEAD one commit back. You could even get the changes back by merging the "bad" commit back without committing the merge (using the `--no-commit` switch).

zeroonetwothree|3 years ago

That’s actually not what git revert does, hence the poor usability of its API.