Skip to content

[feature]: implement Undo/Redo actions#1970

Open
Necrom4 wants to merge 5 commits into
NeogitOrg:masterfrom
Necrom4:feat/undo-redo
Open

[feature]: implement Undo/Redo actions#1970
Necrom4 wants to merge 5 commits into
NeogitOrg:masterfrom
Necrom4:feat/undo-redo

Conversation

@Necrom4

@Necrom4 Necrom4 commented Jun 13, 2026

Copy link
Copy Markdown

Implementation of Lazygit’s reflog undo/redo magic inspired by jesseduffield/lazygit#718

This adds basic undo/redo in the status buffer, bound to <m-u> and <m-r>.

It works off the reflog: undo moves HEAD back to where it was before the last action, and redo steps it forward again. Each move is tagged in the
reflog so your place in the history isn't lost when you close and reopen. It covers things that move HEAD (commits, amends, merges, rebases,
resets) and is disabled while a rebase or merge is in progress.

I used <m-u>/<m-r> rather than z/<c-z> since z is already a fold prefix in the status buffer. This does not close #1839, because it can’t revert simple stages, but I could look into implementing that.

Open to changing the default keys if you'd prefer something else. I may also look into further improvements Lazygit added after this PR, even though from testing this already works exactly how I expected it to, and how I use it everyday with Lazygit.

Necrom4 added 5 commits June 13, 2026 11:00
Undo steps HEAD back through the reflog and redo replays it forward.
Each move is tagged in the reflog so the stack survives reopening
neogit, and both bail out during a rebase or merge.
Adds n_undo/n_redo actions and wires them up in the status buffer.
Plain z is already a fold prefix here, so undo/redo sit on the meta
keys instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support undo/redo for git commands

1 participant