lazygit
lazygit is a terminal UI for git commands, providing a visual interface for staging, committing, branching, and more.
Installation
macOS (Homebrew)
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
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
- Press N for new branch
- Type branch name
- Press Enter
Merging
- Select source branch
- Press Shift+M to merge into current branch
Rebasing
- Select branch to rebase onto
- 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:
- In commits panel, select base commit
- 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 |
Search
| 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:
Recommended Aliases
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
- Stage files: Space on each or A for all
- Commit: C
- Type message, Enter
Fix Last Commit
- Make changes
- Stage: Space
- Amend: Shift+A
Cherry Pick
- Go to commits panel
- Select commit, press C to copy
- Switch to target branch
- Press Shift+V to paste (cherry-pick)
Resolve Conflicts
- Conflicts shown in files panel
- Press Enter to view conflict
- Choose resolution:
- B for both
- O for ours
- T for theirs
- Stage resolved files
- Continue merge/rebase
Clean Up Branches
- Go to branches panel
- Select old branch
- Press D to delete
Troubleshooting
Reset Config
rm ~/.config/lazygit/config.yml
Increase Log Verbosity
Update