Skip to content

lazygit

lazygit is a terminal UI for git commands, providing a visual interface for staging, committing, branching, and more.

Installation

macOS (Homebrew)

brew install lazygit

Linux

# Ubuntu/Debian (via PPA)
LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep -Po '"tag_name": "v\K[^"]*')
curl -Lo lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz"
tar xf lazygit.tar.gz lazygit
sudo install lazygit /usr/local/bin

# Arch Linux
pacman -S lazygit

Verify Installation

lazygit --version

Basic Usage

Launch

# In a git repository
lazygit

# Short alias
lg

Interface Layout

+------------------+------------------+
|     Status       |    Staged        |
|     (1)          |    Changes (3)   |
+------------------+------------------+
|     Files        |    Main Panel    |
|     (2)          |    (5)           |
+------------------+------------------+
|   Local Branches |                  |
|     (3)          |                  |
+------------------+                  |
|   Remote Branches|                  |
|     (4)          |                  |
+------------------+------------------+

Panel Navigation

Key Action
1 - 5 Jump to panel
H / L Previous/next panel
J / K Move up/down in list
[ / ] Scroll main panel
Tab Switch focus
? Show keybindings

Files Panel

Staging

Key Action
Space Stage/unstage file
A Stage all
D Discard changes
E Edit file
O Open file in editor
I Add to .gitignore
Enter Stage individual hunks

Viewing Changes

Key Action
Enter View file diff
Ctrl+O Copy file path

Staging Individual Hunks

Press Enter on a file to enter hunk staging mode:

Key Action
Space Stage/unstage hunk
V Toggle range select
A Stage/unstage all hunks
Esc Return to files

Commits

Creating Commits

Key Action
C Commit
Shift+C Commit with editor
Shift+A Amend last commit
Ctrl+O Copy commit SHA

Viewing Commits

Key Action
Enter View commit diff
O Open commit in browser
Y Copy commit SHA

Commit Operations

Key Action
R Reword commit
D Drop commit
E Edit commit
S Squash into previous
F Fixup into previous
Shift+P Pick commit (for rebase)

Branches

Branch Navigation

Key Action
Space Checkout branch
N New branch
D Delete branch
Shift+M Merge into current
R Rebase onto current
Shift+R Rename branch
F Fetch branch
U Set upstream

Creating Branches

  1. Press N for new branch
  2. Type branch name
  3. Press Enter

Merging

  1. Select source branch
  2. Press Shift+M to merge into current branch

Rebasing

  1. Select branch to rebase onto
  2. Press R to start rebase

Stash

Key Action
S Stash changes
Shift+S Stash staged only
Space Apply stash
G Pop stash
D Drop stash

Remotes

Key Action
F Fetch
Shift+F Fetch all
P Pull
Shift+P Push
Space Checkout remote branch

Force Push

Press Shift+P then select "Force push" when needed.

Interactive Rebase

Start interactive rebase:

  1. In commits panel, select base commit
  2. Press E to start interactive rebase

During rebase:

Key Action
P Pick
R Reword
E Edit
S Squash
F Fixup
D Drop
Ctrl+J / Ctrl+K Move commit
M Continue rebase
Key Action
/ Start search
N Next match
Shift+N Previous match

Configuration

Config File Location

~/.config/lazygit/config.yml

Example Configuration

gui:
  theme:
    lightTheme: false
    activeBorderColor:
      - green
      - bold
    inactiveBorderColor:
      - white
  showFileTree: true
  showRandomTip: false
  showCommandLog: true

git:
  paging:
    colorArg: always
    pager: delta --dark --paging=never
  commit:
    signOff: false
  merging:
    manualCommit: false
    args: ""
  pull:
    mode: rebase
  autoFetch: true
  autoRefresh: true
  branchLogCmd: "git log --graph --color=always --abbrev-commit --decorate --date=relative --pretty=medium {{branchName}} --"

os:
  editCommand: nvim
  editCommandTemplate: "{{editor}} {{filename}}"

keybinding:
  universal:
    quit: q
    quit-alt1: <c-c>
    return: <esc>
    scrollUpMain: <pgup>
    scrollDownMain: <pgdown>

Editor Integration

os:
  editCommand: nvim
  # Or for VS Code
  # editCommand: code
  # editCommandTemplate: "{{editor}} --wait {{filename}}"

Use Delta for Diffs

git:
  paging:
    colorArg: always
    pager: delta --dark --paging=never

Custom Commands

Add custom commands in config:

customCommands:
  - key: "<c-f>"
    command: "git fetch --all"
    context: "global"
    description: "Fetch all remotes"

  - key: "<c-r>"
    command: "gh pr create --fill"
    context: "global"
    description: "Create PR"

  - key: "C"
    command: "git commit -m '{{index .PromptResponses 0}}'"
    context: "files"
    prompts:
      - type: "input"
        title: "Commit message"

Editor Integration

Neovim/LazyVim

lazygit is integrated with LazyVim. Press Space+G+G to open.

VS Code

Install "lazygit" extension or use terminal:

{
  "terminal.integrated.profiles.osx": {
    "lazygit": {
      "path": "lazygit"
    }
  }
}

Zed

Use terminal panel:

lazygit

Add to ~/.bashrc or ~/.zshrc:

alias lg='lazygit'
alias lzg='lazygit'

Global Keybindings

Key Action
? Show all keybindings
X Show command menu
Z Undo
Ctrl+Z Redo
Esc Cancel/return
Q Quit
Ctrl+C Quit
+ Expand diff context
- Shrink diff context

Common Workflows

Quick Commit

  1. Stage files: Space on each or A for all
  2. Commit: C
  3. Type message, Enter

Fix Last Commit

  1. Make changes
  2. Stage: Space
  3. Amend: Shift+A

Cherry Pick

  1. Go to commits panel
  2. Select commit, press C to copy
  3. Switch to target branch
  4. Press Shift+V to paste (cherry-pick)

Resolve Conflicts

  1. Conflicts shown in files panel
  2. Press Enter to view conflict
  3. Choose resolution:
  4. B for both
  5. O for ours
  6. T for theirs
  7. Stage resolved files
  8. Continue merge/rebase

Clean Up Branches

  1. Go to branches panel
  2. Select old branch
  3. Press D to delete

Troubleshooting

Reset Config

rm ~/.config/lazygit/config.yml

Increase Log Verbosity

lazygit --debug

Update

brew upgrade lazygit