Skip to main content

Overview

LazyGit is a simple terminal UI for git commands that integrates seamlessly with Neovim. The Magictt config provides easy access to LazyGit’s powerful interface for managing git operations without leaving your editor.

What LazyGit Does

  • Git Interface: Full-featured git UI in a terminal window
  • Visual Git Operations: Stage, commit, push, pull, and more with keyboard shortcuts
  • Branch Management: Create, switch, merge, and rebase branches visually
  • Commit History: Browse and search through commit history
  • Diff Viewing: View file changes with syntax highlighting
  • Conflict Resolution: Handle merge conflicts interactively

Configuration

The LazyGit plugin configuration:
return {
    "kdheepak/lazygit.nvim",
    lazy = true,
    cmd = {
        "LazyGit",
        "LazyGitConfig",
        "LazyGitCurrentFile",
        "LazyGitFilter",
        "LazyGitFilterCurrentFile",
    },
    -- optional for floating window border decoration
    dependencies = {
        "nvim-lua/plenary.nvim",
    },
    -- setting the keybinding for LazyGit with 'keys' is recommended in
    -- order to load the plugin when the command is run for the first time
    keys = {
        { "<leader>ll", "<cmd>LazyGit<cr>", desc = "LazyGit" }
    }
}
Source: lua/magictt/plugins/lazygit.lua:1-22

Plugin Features

Lazy Loading

lazy = true
The plugin is lazy-loaded, meaning:
  • Doesn’t load on Neovim startup
  • Only loads when you first use a LazyGit command
  • Improves startup time
  • No performance impact until needed

Available Commands

cmd = {
    "LazyGit",
    "LazyGitConfig",
    "LazyGitCurrentFile",
    "LazyGitFilter",
    "LazyGitFilterCurrentFile",
}
These commands trigger plugin loading:
CommandDescription
:LazyGitOpen LazyGit in a floating window
:LazyGitConfigOpen LazyGit configuration
:LazyGitCurrentFileOpen LazyGit focused on current file
:LazyGitFilterOpen LazyGit with commit filter
:LazyGitFilterCurrentFileFilter commits for current file

Dependencies

dependencies = {
    "nvim-lua/plenary.nvim",
}
Requires plenary.nvim for:
  • Floating window management
  • Border decoration
  • Utility functions

Keybindings

Neovim Keybinding

KeyActionDescription
<leader>llOpen LazyGitOpens LazyGit interface in floating window
Source: lua/magictt/plugins/lazygit.lua:19
The <leader>l prefix opens the “Lazy panels” menu in which-key, where you can access LazyGit.

LazyGit Interface Keybindings

Once inside LazyGit, these keybindings are available:
KeyAction
j/kMove down/up
h/lMove between panels
[/]Previous/next tab
< / >Scroll left/right
PgUp/PgDnScroll page up/down

Files Panel

KeyAction
<space>Stage/unstage file
aStage/unstage all files
dView diff options
DReset (discard changes)
eEdit file
oOpen file
cCommit changes
CCommit using git commit editor
AAmend last commit

Commits Panel

KeyAction
<enter>View commit files
cCheckout commit
CCopy commit SHA
rRebase
RRename commit
dDelete commit
sSquash commit
fFixup commit
tRevert commit
TTag commit

Branches Panel

KeyAction
<space>Checkout branch
nNew branch
dDelete branch
DForce delete branch
rRebase branch
MMerge branch
fFast-forward branch
FCreate pull request

Stash Panel

KeyAction
<space>Apply stash
gPop stash
dDrop stash

Global Commands

KeyAction
?View help/keybindings
qQuit LazyGit
<esc>Cancel/go back
PPush to remote
pPull from remote
RRefresh
:Execute custom command
wOpen worktree menu

Usage

Opening LazyGit

  1. Press <leader>ll in Neovim
  2. LazyGit opens in a floating window
  3. Use h/j/k/l to navigate
  4. Press ? to see all keybindings

Basic Git Workflow

Staging and Committing

  1. Open LazyGit: <leader>ll
  2. View changed files: Files panel shows modified files
  3. Stage files:
    • Navigate to file with j/k
    • Press <space> to stage
    • Or press a to stage all
  4. Commit:
    • Press c to commit
    • Type commit message
    • Press <enter> to confirm
  5. Push: Press P to push to remote

Working with Branches

  1. View branches: Press [ or ] to navigate to branches tab
  2. Create branch: Press n, type name, press <enter>
  3. Switch branch: Navigate to branch, press <space>
  4. Merge branch: Navigate to branch, press M
  5. Delete branch: Navigate to branch, press d

Viewing History

  1. View commits: Navigate to commits tab with [/]
  2. View commit details: Press <enter> on a commit
  3. View file changes: Navigate through changed files
  4. Copy commit SHA: Press C on a commit

Handling Conflicts

  1. When conflicts occur: LazyGit highlights conflicted files
  2. Navigate to file: Use j/k to select conflicted file
  3. Open editor: Press e to edit in Neovim
  4. Resolve conflicts: Edit file manually
  5. Stage resolved file: Return to LazyGit, press <space> on file
  6. Continue merge/rebase: Follow prompts

Advanced Operations

Interactive Rebase

  1. Navigate to commits tab
  2. Press r on the base commit
  3. Select commits to rebase
  4. Choose actions (squash, fixup, reword, etc.)
  5. Follow prompts to complete rebase

Stashing Changes

  1. In files panel, press s to stash
  2. Navigate to stash tab with [/]
  3. Press <space> to apply stash
  4. Press g to pop stash (apply and delete)

Cherry-picking

  1. Navigate to commits tab
  2. Select commit with j/k
  3. Press c to copy commit
  4. Navigate to target branch
  5. Press v to paste (cherry-pick)

Commands Reference

:LazyGit

Opens LazyGit in a floating window:
:LazyGit
Or use the keybinding: <leader>ll

:LazyGitCurrentFile

Opens LazyGit focused on the current file’s history:
:LazyGitCurrentFile
Useful for:
  • Viewing file-specific commit history
  • Seeing who changed a file
  • Tracking file evolution

:LazyGitFilter

Opens LazyGit with a commit filter:
:LazyGitFilter
Enter a filter pattern to search commits by:
  • Commit message
  • Author
  • Date range
  • File changes

:LazyGitFilterCurrentFile

Filters commits to show only those affecting the current file:
:LazyGitFilterCurrentFile
Combines filter and current file focus.

:LazyGitConfig

Opens LazyGit configuration file:
:LazyGitConfig
Allows customizing LazyGit settings:
  • Color scheme
  • Keybindings
  • UI preferences
  • Git command aliases

Tips and Tricks

Quick Commit and Push

  1. <leader>ll - Open LazyGit
  2. a - Stage all files
  3. c - Commit
  4. Type message and <enter>
  5. P - Push
  6. q - Quit back to Neovim

Amending Last Commit

  1. Make changes in Neovim
  2. <leader>ll - Open LazyGit
  3. a - Stage changes
  4. A - Amend commit (capital A)
  5. Edit message if needed
  6. <enter> - Confirm

Viewing File History

  1. Open the file you want to investigate
  2. :LazyGitCurrentFile
  3. Browse commits affecting this file
  4. Press <enter> on a commit to see changes

Undoing Last Commit

  1. <leader>ll - Open LazyGit
  2. Navigate to commits tab
  3. Select the commit to undo
  4. Press t to revert
  5. Or press d to delete (if not pushed)

Interactive Staging

To stage parts of a file:
  1. <leader>ll - Open LazyGit
  2. Navigate to file
  3. Press d for diff options
  4. Press <enter> to open in patch mode
  5. Select hunks to stage with <space>

Working with Remotes

  1. Press f to fetch from all remotes
  2. Press p to pull from current remote
  3. Press P to push to current remote
  4. Press <shift-P> for push options (force, set upstream, etc.)

Customization

LazyGit Config Location

LazyGit configuration is separate from Neovim:
  • Linux/Mac: ~/.config/lazygit/config.yml
  • Windows: %APPDATA%\lazygit\config.yml
Access with :LazyGitConfig

Custom Colors

Edit LazyGit config to match your Neovim theme:
gui:
  theme:
    activeBorderColor:
      - '#ff9e64'
      - bold
    inactiveBorderColor:
      - '#a9b1d6'
    selectedLineBgColor:
      - '#364A82'

Custom Keybindings

Add custom keybindings in LazyGit config:
keybinding:
  universal:
    quit: 'q'
    return: 'esc'
  files:
    commitChanges: 'c'
    amendLastCommit: 'A'

Window Size

The plugin uses a floating window by default. To customize the window size, you would need to modify the plugin configuration (not shown in the current config).

Troubleshooting

LazyGit Not Opening

If LazyGit doesn’t open:
  1. Check if lazygit is installed:
    lazygit --version
    
  2. Install lazygit if missing:
    • Mac: brew install lazygit
    • Linux: sudo pacman -S lazygit or equivalent
    • Windows: choco install lazygit
  3. Verify plugin is loaded:
    :Lazy
    
    Look for lazygit.nvim

Keybinding Not Working

If <leader>ll doesn’t work:
  1. Check which-key is configured properly
  2. Verify the keybinding in lua/magictt/plugins/lazygit.lua:19
  3. Try the command directly: :LazyGit

Display Issues

If LazyGit looks broken:
  1. Ensure your terminal supports colors:
    echo $TERM
    
  2. Use a terminal with full color support (xterm-256color)
  3. Check LazyGit config for color settings

Git Not Found

If you get a “git not found” error:
  1. Ensure git is installed:
    git --version
    
  2. Add git to your PATH
  3. Restart Neovim
  • Which-key - Keybinding reference for <leader>l group
  • Telescope - Alternative for finding commits and files

External Resources

Build docs developers (and LLMs) love