lazygit
Simple terminal UI for git commands.
Official WebsiteFeatures
Installation
brew install lazygitpacman -S lazygitchoco install lazygitWhy use lazygit?
lazygit is a TUI (Terminal User Interface) tool that allows intuitive Git operations on the terminal. You can perform advanced Git operations with just keyboard commands, without needing to memorize complex Git commands.
Intuitive UI
View status, staging, commit history, and branches on one screen. Understand state visually.
Interactive Rebase
Reorder commits, squash, and fixup with drag-and-drop-like operations.
Branch Management
Create, switch, merge, and rebase branches with a single key. Even complex operations are simple.
Conflict Resolution
Visually review merge conflicts and choose which changes to apply.
Interface
lazygit screen layout: Status, staging, commit history, and branches can be viewed at a glance.
Installation
# macOS (Homebrew)
brew install lazygit
# Ubuntu/Debian
sudo add-apt-repository ppa:lazygit-team/release
sudo apt-get update
sudo apt-get install lazygit
# Arch Linux
sudo pacman -S lazygit
# Install with Go
go install github.com/jesseduffield/lazygit@latest
# Conda
conda install -c conda-forge lazygitBasic Usage
Startup
# Run inside Git repository
lazygit
# Launch at specific path
lazygit -p /path/to/repo
# Specify config file location
lazygit --use-config-file="~/.config/lazygit/config.yml"Key Bindings
| Key | Action | Description |
|---|---|---|
Space | Staging | Stage/unstage file |
c | Commit | Enter commit message and commit |
p | Push | Push to remote |
P | Pull | Pull from remote |
n | New Branch | Create new branch |
M | Merge | Merge selected branch |
r | Rebase | Rebase onto selected branch |
s | Squash | Squash commit |
e | Edit | Edit commit message |
d | Delete | Delete commit/branch |
? | Help | Show key binding list |
q | Quit | Exit lazygit |
Main Features
Staging Operations
Staging is possible not just at the file level, but also at the line and hunk level.
# File screen
Space # Stage/unstage entire file
Enter # Show file diff
Tab # Toggle between staged/unstaged
# Diff display screen
Space # Stage line/hunk
a # Stage all changes
v # Range selection modeCommit Operations
# Commit screen
c # New commit
A # Amend to previous commit
s # Squash (combine with commit below)
f # Fixup (squash without message)
r # Reword commit message
d # Delete commit (dangerous)
Ctrl+j # Move commit down
Ctrl+k # Move commit upBranch Operations
# Branch screen
n # Create new branch
Space # Checkout
M # Merge into current branch
r # Rebase onto selected branch
R # Rename remote branch
d # Delete branch
f # Fetch
F # Force fetchMerge & Rebase
# Interactive rebase
i # Start interactive rebase
Ctrl+j/k # Change commit order
s # Squash
f # Fixup
d # Drop (delete)
e # Edit (edit commit)
# Conflict resolution
Enter # Open conflict file
Space # Select ours/theirs
b # Accept both changesConfiguration & Customization
Configuration File
Customize settings in ~/.config/lazygit/config.yml.
# ~/.config/lazygit/config.yml
gui:
# Theme settings
theme:
activeBorderColor:
- green
- bold
inactiveBorderColor:
- white
selectedLineBgColor:
- blue
# Enable mouse
mouseEvents: true
# Scroll height
scrollHeight: 2
git:
# Use --rebase for pull
pull:
mode: 'rebase'
# Auto fetch
autoFetch: true
autoFetchInterval: 120
# Customize key bindings
keybinding:
universal:
quit: 'q'
return: '<esc>'
scrollUpMain: '<pgup>'
scrollDownMain: '<pgdown>'Custom Commands
# Add custom command
customCommands:
- key: 'C'
context: 'files'
command: 'git commit -m "{{.Form.Message}}"'
description: 'Custom commit'
prompts:
- type: 'input'
title: 'Commit message'
key: 'Message'
initialValue: ''Tips & Tricks
- *Press
?anytime to show help. You can see key bindings available in the current panel - *Press
@to show command log. You can see which Git commands have been executed - *Press
+to start cherry-pick mode from the selected commit - *Press
ctrl+oto open files in the default editor - *Press
/to use filtering search. You can quickly find commits and branches - *When Git hooks (like pre-commit) fail, error messages are displayed making it easy to identify the cause