2 ms·
My brain immediately jumped to "but you can just git reflog and then copy the state you want to revert to and then git reset --hard <commit>", but not only is t
by mikepurvis 4y ago
My brain immediately jumped to "but you can just git reflog and then copy the state you want to revert to and then git reset --hard <commit>", but not only is that not simple or obvious, it isn't even correct, since a commit or amend operation can be performed with only some of the changes staged, and a hard reset will wipe out anything unstaged. Ah sigh.
So yes, in short I agree.
- latifk 4y agoWell in that situation you can stash unstaged, reset, then pop. But that just reinforces the OP’s point. Not the most ergonomic or discoverable path for something that should be simple to do.
- michaelmior 4y agogit reset HEAD@{1} should do the trick to "uncommit" and keep uncommitted changes in the absence of conflicts. (I may be missing some edge cases.) It does however unstage changes.
- galaxyLogic 4y agoRight and it is not obvious: git reset HEAD@{1} .
- acchow 4y agoRight, if you grok the git model then this makes sense. But if you just want to use a tool without learning how it manages state, git is a pain.
- srcreigh 4y agoIsn’t this just git reset —soft HEAD~1? Put my stuff from the last commit back into working directory? Very unintuitive (soft?) and I’ve just memorized this for the past 10 years.
- mikepurvis 4y agohttps://xkcd.com/1597/ https://xkcd.com/1597/