Managing Git repositories via standard command-line flags requires memorising numerous combinations of git add, git commit, git rebase, and git stash commands. While graphical interfaces (GUIs) offer convenience, they pull developers away from their terminal workflows. lazygit provides an elegant middle ground: a fast, keyboard-driven terminal user interface (TUI) written in Go that streamlines branching, staging, conflict resolution, and commit history.
Why Developers Prefer Lazygit Over Standard Git CLI
Working inside a terminal interface with lazygit accelerates version control tasks significantly:
- Interactive Staging: Stage individual files, discarded hunks, or single lines with single-key presses rather than navigating complex patch flags.
- Interactive Rebasing: Squash, edit, reword, or drop past commits visually without hand-editing temporary git rebase files.
- Unified Dashboard: Displays status, files, local and remote branches, commits, and stashes across five modular panels simultaneously.
- Lightweight Resource Footprint: Runs entirely within your shell environment or multiplexers like tmux without demanding desktop window management overhead.
Installing Lazygit Across Major Linux Distributions
You can install lazygit through various distribution package managers or download the pre-compiled binary:
- Ubuntu and Debian (via Official PPA):
sudo add-apt-repository ppa:lazygit-team/release sudo apt update sudo apt install lazygit - Fedora (via Copr):
sudo dnf copr enable atim/lazygit -y sudo dnf install lazygit - Arch Linux and Manjaro:
sudo pacman -S lazygit - Homebrew for Linux:
brew install lazygit - Manual Binary Installation (Go Environment):
go install github.com/jesseduffield/lazygit@latest
Navigating the Lazygit Interface and Core Panels
To launch the interface, navigate to any valid Git repository directory in your terminal and type:
lazygit
The dashboard presents five key panels on the left-hand side, alongside a large diff preview window on the right:
- Status (1): Shows repository branch status, tracking state, and remote configuration.
- Files (2): Lists unstaged, modified, and untracked files. Pressing
spacestages or unstages a file; pressingcprompts for a commit message. - Branches (3): Displays local and remote branches. Press
spaceto checkout; pressnto spawn a new branch from your current HEAD. - Commits (4): Displays commit logs. Press
sto squash commits, orrto reword commit titles directly. - Stash (5): Manages your stashed changes, allowing you to pop, apply, or drop changes with instantaneous visual previews.
Use keys 1 through 5, or the [ and ] brackets, to jump between panels instantly.
Essential Keyboard Shortcuts for Daily Git Operations
Mastering a few key bindings enables you to handle routine version control in seconds:
- Pushing and Pulling: Press
P(Shift + P) to push changes to the remote branch; presspto pull incoming upstream commits. - Discarding Changes: Highlight a modified file or hunk and press
dto discard uncommitted edits safely. - Line-by-Line Staging: In the Files panel, press
Enteron a file to enter diff view. Highlight specific lines and pressspaceto stage only selected changes. - Contextual Help: Press
?anywhere insidelazygitto display the complete shortcut map for your active panel. - Quit: Press
qto exit the interface and return to your terminal prompt.