How to Install and Use Lazygit in Linux Terminal for Simple Git Workflows

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:

  1. Status (1): Shows repository branch status, tracking state, and remote configuration.
  2. Files (2): Lists unstaged, modified, and untracked files. Pressing space stages or unstages a file; pressing c prompts for a commit message.
  3. Branches (3): Displays local and remote branches. Press space to checkout; press n to spawn a new branch from your current HEAD.
  4. Commits (4): Displays commit logs. Press s to squash commits, or r to reword commit titles directly.
  5. 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; press p to pull incoming upstream commits.
  • Discarding Changes: Highlight a modified file or hunk and press d to discard uncommitted edits safely.
  • Line-by-Line Staging: In the Files panel, press Enter on a file to enter diff view. Highlight specific lines and press space to stage only selected changes.
  • Contextual Help: Press ? anywhere inside lazygit to display the complete shortcut map for your active panel.
  • Quit: Press q to exit the interface and return to your terminal prompt.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.