Skip to main content
Git keymaps are distributed across multiple plugins, each serving different purposes. This page consolidates all git-related keymaps for easy reference.
Git functionality is split across five plugins:
  • Gitsigns - Buffer-level hunk operations
  • Snacks - Pickers and browser integration
  • Neogit - Full git UI
  • CodeDiff - Side-by-side diffs
  • Toggleterm - Lazygit and terminal git commands

Gitsigns (hunk operations)

Manage git hunks directly in the current buffer. Keymaps defined in lua/plugins/git.lua:66.

Hunk navigation

KeyModeDescription
[gnormalPrevious git hunk
]gnormalNext git hunk
Hunk navigation wraps around and targets all hunks (staged and unstaged) using target = "all".

Hunk preview

KeyModeDescription
<leader>gPnormalPreview hunk (floating popup)
<leader>gpnormalPreview hunk (inline overlay)

Hunk staging

KeyModeDescription
<leader>ganormalStage hunk (git add)
<leader>gunormalUnstage hunk
<leader>gAnormalStage entire buffer
<leader>gu toggles the stage state for the current hunk. This replaces the deprecated undo_stage_hunk() function.

Hunk reset

KeyModeDescription
<leader>grnormalReset hunk (discard changes)
<leader>gRnormalReset entire buffer (discard all changes)
Reset operations discard changes permanently. Use preview keymaps first to verify what will be removed.

Blame

KeyModeDescription
<leader>gbnormalBlame line (popup with commit info)
<leader>gBnormalBlame buffer (full buffer view)
<leader>GBnormalToggle inline blame (virtual text)
Inline blame shows commit info at the end of each line. The formatter replaces your git username with “You” for clarity. See lua/plugins/git.lua:39.

Diff

KeyModeDescription
<leader>gDnormalDiff buffer vs HEAD (vim split)

Snacks (pickers and browser)

Git pickers and browser integration. Keymaps defined in lua/plugins/snacks.lua:108.
KeyModeDescription
<leader>glnormalGit log for current line
<leader>gdnormalGit diff hunks (picker)
<leader>gSnormalGit stash browser (picker)
<leader>gonormal, visualOpen file/selection on GitHub
<leader>gl shows commits that specifically modified the current line, different from full repo history.
<leader>go opens files in Google Chrome by default. The browser is configured at lua/plugins/snacks.lua:126.

Neogit (main git UI)

Full interactive git interface. Keymaps defined in lua/plugins/git.lua:252.
KeyModeDescription
<leader>gnnormalOpen Neogit status panel
<leader>gcnormalNeogit commit (skip status)
Neogit provides a full git UI for staging, committing, pushing, pulling, rebasing, stashing, and more. Press ? inside Neogit for all available actions.

Neogit features

Neogit integrates with CodeDiff and Snacks for enhanced functionality:
integrations = {
  codediff = true,
  snacks = true,
}
diff_viewer = "codediff"
See lua/plugins/git.lua:268.

CodeDiff (side-by-side diffs)

Advanced diff viewer with staging support. Keymaps defined in lua/plugins/git.lua:199.
KeyModeDescription
<leader>ddnormalToggle CodeDiff explorer
<leader>dhnormalFile history (all files)
<leader>d.normalCurrent file history
<leader>dfnormalCurrent file diff vs HEAD
<leader>dmnormalMerge-base diff vs origin/main
<leader>dMnormalMerge-base diff vs custom branch
CodeDiff shows uncommitted changes with side-by-side staging. Press g? inside the view for help and gm to align moved lines.
Merge-base diffs (<leader>dm) show only changes introduced since branching, similar to GitHub PR diffs.

Lazygit (terminal UI)

Alternative terminal-based git UI. Keymaps defined in lua/plugins/toggleterm.lua:217.
KeyModeDescription
<leader>ggnormalLazygit in floating terminal
<leader>GDnormalGit diff for current file (with delta)
Lazygit is an alternative to Neogit with a different workflow. Use whichever you prefer.

Configuration comparison

Gitsigns uses custom signs for different change types:
TypeSignDescription
addNew lines
changeModified lines
delete_Deleted lines
topdeleteDeleted at top
changedelete~Changed and deleted
untrackedUntracked files
Staged signs use the same icons. See lua/plugins/git.lua:6.

Workflow recommendations

For quick hunk-level changes, use Gitsigns keymaps. For commits and complex operations, use Neogit or Lazygit. For reviewing changes before committing, use CodeDiff.

Common workflows

  1. Review changes: <leader>dd (CodeDiff) or <leader>gd (Snacks hunks)
  2. Stage hunks: <leader>ga (stage) → <leader>gc (commit)
  3. Full git UI: <leader>gn (Neogit) → press ? for help
  4. Quick commit: <leader>gA (stage all) → <leader>gc (commit)
  5. Blame investigation: <leader>gb (line) → <leader>gl (line history)
Be careful with reset operations (<leader>gr, <leader>gR) as they discard changes without confirmation.

Build docs developers (and LLMs) love