Pick files changed between a selected Git branch and HEAD with snacks.nvim.
- Neovim 0.12+
- Git
- snacks.nvim with picker enabled
{
"goropikari/gitdiff.nvim",
dependencies = { "folke/snacks.nvim" },
opts = {},
}:GitDiffFiles: open the changed-file picker usingSnacks.picker.git_diff({ group = true }). If no branch is remembered for the current worktree, opens the branch picker first.:GitDiffBranch: choose a base branch, remember it for the current worktree, then open the changed-file picker.:GitDiffReset: forget the remembered branch for the current worktree.
require("gitdiff").files()
require("gitdiff").branch()
require("gitdiff").reset()
require("gitdiff").reset({ all = true })gitdiff.nvim delegates the main file picker to snacks.nvim:
Snacks.picker.git_diff({
base = branch.refname,
group = true,
})The selected branch is remembered only for the current Neovim session and is keyed by git rev-parse --show-toplevel, so separate worktrees can remember different base branches.