Skip to main content
Gitsigns shows git diff information in the sign column and provides commands for managing hunks directly from Neovim.

Configuration

Gitsigns is configured in lua/user/gitsigns.lua.

Sign Column Indicators

Git changes are displayed in the sign column with these symbols:
signs = {
  add          = { text = ' ' },
  change       = { text = ' ' },
  delete       = { text = ' ' },
  topdelete    = { text = '󱅁 ' },
  changedelete = { text = '󰍷 ' },
}

Features

signcolumn = true,        -- Show signs in sign column
numhl = false,            -- Highlight line numbers
linehl = false,           -- Highlight lines
word_diff = false,        -- Show word diff
current_line_blame = false,  -- Show blame info (toggle with command)

Keybindings

All git commands are under the <leader>g prefix.
KeyActionDescription
<leader>gjNext hunkJump to next change
<leader>gkPrev hunkJump to previous change

Viewing Changes

KeyActionDescription
<leader>gpPreview hunkShow diff in floating window
<leader>glBlame lineShow git blame for current line
<leader>gdDiffShow diff against HEAD

Staging & Resetting

KeyActionDescription
<leader>gsStage hunkStage the current hunk
<leader>guUndo stageUndo last stage operation
<leader>grReset hunkDiscard changes in hunk
<leader>gRReset bufferDiscard all changes in file

Git Tools

KeyActionDescription
<leader>ggLazygitOpen Lazygit terminal
<leader>goGit statusBrowse changed files
<leader>gbBranchesCheckout git branch
<leader>gcCommitsBrowse and checkout commits

Commands

Toggle Features

:Gitsigns toggle_signs          " Toggle sign column
:Gitsigns toggle_numhl          " Toggle number highlighting
:Gitsigns toggle_linehl         " Toggle line highlighting
:Gitsigns toggle_word_diff      " Toggle word diff
:Gitsigns toggle_current_line_blame  " Toggle blame info

Hunk Operations

:Gitsigns stage_hunk            " Stage current hunk
:Gitsigns reset_hunk            " Reset current hunk
:Gitsigns undo_stage_hunk       " Undo staging
:Gitsigns preview_hunk          " Preview hunk diff

Buffer Operations

:Gitsigns stage_buffer          " Stage all hunks in buffer
:Gitsigns reset_buffer          " Reset all hunks in buffer

Blame

:Gitsigns blame_line            " Show blame for current line
:Gitsigns toggle_current_line_blame  " Toggle inline blame

Usage Examples

Reviewing Changes

  1. Navigate between changes:
    <leader>gj  " Next change
    <leader>gk  " Previous change
    
  2. Preview the change:
    <leader>gp  " Shows diff in floating window
    
  3. Stage or reset:
    <leader>gs  " Stage this hunk
    <leader>gr  " Discard this hunk
    

Working with Hunks

A “hunk” is a contiguous block of changes. Gitsigns lets you stage or reset individual hunks:
" Stage specific hunks
<leader>gs

" Undo if you staged wrong
<leader>gu

" Reset unwanted changes
<leader>gr

Viewing Git Blame

See who changed a line and when:
" Show blame for current line
<leader>gl

" Toggle inline blame (shows at end of every line)
:Gitsigns toggle_current_line_blame

Comparing Changes

" Show diff in split window
<leader>gd

" This runs: :Gitsigns diffthis HEAD

Configuration Options

Update Frequency

watch_gitdir = {
  interval = 1000,        -- Check for changes every second
  follow_files = true,    -- Follow file moves
}

Preview Window

preview_config = {
  border = "single",
  style = "minimal",
  relative = "cursor",
}

Performance

max_file_length = 40000,  -- Disable for files longer than 40k lines
update_debounce = 100,    -- Debounce updates (ms)

Integration with Other Tools

Telescope

Gitsigns integrates with Telescope for browsing:
  • <leader>go - Browse changed files
  • <leader>gb - Browse branches
  • <leader>gc - Browse commits

Lazygit

Quickly open Lazygit terminal UI:
<leader>gg
Use <leader>gp to preview hunks before staging them. This helps avoid staging unwanted changes.
Line blame information includes the commit hash, author, and relative time of the change.

Tips

  • Navigate hunks with <leader>gj and <leader>gk
  • Preview before staging with <leader>gp
  • Use <leader>gg for complex git operations via Lazygit
  • Enable inline blame for detailed change history
  • Stage hunks individually for cleaner commits

Build docs developers (and LLMs) love