3 ms·
This is an awesome idea. Can't wait to hear the objections from the purists.
by Simplicitas 5y ago
This is an awesome idea.
Can't wait to hear the objections from the purists.
- idoubtit 5y agoI've watched the first case: amend a commit then undo. And I believe it shows serious shortcomings : - The interactive interface of `git undo` is probably too hard for beginners. Designing simple interfaces is hard, and you can't pplease everyone. - It seems `git undo` simply does a `git reset--hard` toward a designed commit. The user probably expected to return to the state before the last git action. Instead `git undo` reverted the amend, but also reset the index and remove the local changes. At this point, the beginner could scream "Undo lost my changes! I just wanted a second commit instead of an amend." Undoing could mean `git reset --hard {hash}`, but in many cases `--hard` would have unwanted effect and the default `--mixed` would be more suitable. But even in this case, it's not a full undo, since the index is not preserved: you don't end up in the same state as before the `commit --amend`.
- arxanas 5y agoThere is a design to address undoing changes to the index: https://github.com/arxanas/git-branchless/issues/10 https://github.com/arxanas/git-branchless/issues/10 It runs a `git checkout`, not a `git reset --hard`, so it will stop you if there are incompatible changes. Of course, if `git undo` can be made to lose your staged or unstaged work, then that's a bug. Fortunately, you can undo the result of any `git undo` with another `git undo` that goes one more step back in time.
- spicybright 5y agoWhy is it so hard to implement a git undo? You have a previous state, and a current state. Just roll it back.
- RichardCA 5y agoThe purist will say: You are always free to write your own porcelain.