Undo
Undo works on Git too.
Git has no undo button. Almost everything can be recovered, but each mistake has its own command, and discarded changes that were never committed are gone. Before every commit, branch deletion, stash drop and discard, Nori keeps a snapshot, so ⌘Z takes it back.
Why Git has no undo
Git records snapshots of your work as commits, and branches are labels pointing at them. An operation moves labels, writes new commits, or rewrites files in the working tree. Each kind is reversed differently, and Git keeps no single list of what you did, so there is no one command to take the last action back.
What Git does keep is the reflog: every position HEAD and each branch held recently. That makes lost commits recoverable, if you know where to look. Changes you discard before committing are a different matter: Git never stored them, so it cannot give them back.
Undoing by hand
| Mistake | The usual fix in the terminal |
|---|---|
| Committed too early | git reset --soft HEAD~1 puts the changes back in staging. |
| Deleted the wrong branch | Find its tip in git reflog, then git branch name <hash>. |
| Dropped a stash | Hunt for the dangling commit with git fsck --unreachable, then git stash apply <hash>. |
| Discarded changes | Nothing, unless they had been staged at some point and not yet collected by Git. |
How undo works in Nori
Before an operation that can be taken back, Nori keeps what it takes to go back, inside the same Git action, and records it once the action succeeds. Then a notice offers Undo for 8 seconds, and ⌘Z, outside a text field, does the same. On Windows and Linux the key is Ctrl+Z.
- A commit is undone by moving the branch back, with its changes staged again. The undone commit can itself be taken back, which moves the branch forward to it again.
- A deleted branch is recreated at its tip, under its name.
- A dropped stash is stored again.
- Discarded changes, untracked files included, come back from their snapshot.
Thirty days of operations
Missed the notice? ⌥⌘Z opens Operations (Alt+Shift+Z on Windows and Linux): every operation Nori can take back from the last 30 days, newest first, each with its hash and subject or its list of files. Pick one to undo it.
For everything else, History can show the reflog entries since Nori 1.13 and restore an earlier state of the repository, the same recovery the terminal offers with git reflog, without copying hashes.
Kept first, then done
An undo you cannot count on is worse than none. Nori keeps the snapshot before the operation deletes anything: the commits a deleted branch pointed to, the stash being dropped, the files being discarded. Only once Git has finished the action is it recorded as undoable, and an action that changed nothing leaves nothing behind.
If a branch’s snapshot cannot be saved, Nori does not delete the branch: it never goes without a way back. That is the difference from the terminal, where the safety net is whatever Git happens not to have collected yet.
Where the snapshots live
Snapshots are kept on your computer, outside the repository. They never appear in git log --all, and no push sends them, not even git push --mirror. They expire with the 30-day list, and those of repositories you never reopen are removed after 31 days.
What undo does not cover
- Push and force push are not undoable: they reach other people. They keep their confirmations instead.
- Aborting a merge, rebase or cherry-pick is not in the list either. A rebase you finished can be walked back from the reflog in History.
- Each operation can be taken back once, and only operations made in Nori are recorded. A commit made in the terminal is still in the reflog, but not in Operations.