Git

Install and Use lazygit – Terminal UI for Git on Linux and macOS

Lazygit is a terminal UI for Git that lets you stage files, commit, push, pull, resolve merge conflicts, rebase interactively, and manage branches – all without typing git commands. It runs on Linux, macOS, FreeBSD, and Windows.

Original content from computingforgeeks.com - post 3280

This guide covers installing the latest lazygit (v0.60.0) on Linux and macOS using multiple methods, then walks through the most common workflows.

Prerequisites

  • Git installed on your system
  • A terminal emulator (any will work)

Install lazygit on Linux (Binary Method)

The fastest way to install lazygit on any Linux distribution is downloading the pre-built binary from GitHub releases. This works on Ubuntu, Debian, Fedora, Rocky Linux, Arch, and any other distro.

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/
rm -f lazygit lazygit.tar.gz

This automatically fetches the latest version. For ARM64 systems (like AWS Graviton or Raspberry Pi), replace x86_64 with arm64 in the URL.

Verify the installation:

lazygit --version

The output should show the installed version:

commit=, build date=, build source=binaryRelease, version=0.60.0, os=linux, arch=amd64

Install lazygit on Ubuntu / Debian

On Ubuntu and Debian, you can install lazygit from the official Go binary (shown above) or use the community PPA if you prefer apt-managed updates:

sudo add-apt-repository ppa:lazygit-team/release
sudo apt update
sudo apt install -y lazygit

Install lazygit on Fedora

On Fedora, lazygit is available from the Terra repository or Copr:

sudo dnf copr enable atim/lazygit -y
sudo dnf install -y lazygit

Install lazygit on Arch Linux

Lazygit is in the Arch community repository:

sudo pacman -S lazygit

Install lazygit on macOS

Use Homebrew to install lazygit on macOS:

brew install lazygit

Using lazygit

Navigate to any Git repository in your terminal and run:

lazygit

The interface opens with panels for files, branches, commits, and stash on the left, and a diff/log view on the right:

lazygit terminal UI showing git status, branches, and commits

Navigate between panels with Tab or number keys (1-5). Use arrow keys or h/j/k/l to move within a panel.

Common Workflows

Stage and commit files: Navigate to the Files panel, press Space to stage/unstage files, then c to open the commit message editor. Type your message and press Enter to commit.

Push and pull: Press P (uppercase) to push, p (lowercase) to pull from the remote.

Create and switch branches: Go to the Branches panel, press n to create a new branch, or Space to checkout an existing one.

Interactive rebase: In the Commits panel, press e to edit a commit, s to squash, r to reword, or d to drop. Move commits up/down with ctrl+j/ctrl+k.

Resolve merge conflicts: When conflicts exist, lazygit shows a diff panel. Use arrow keys to navigate between conflicts, Space to pick a hunk, or b to accept both sides.

Stash changes: Press s in the Files panel to stash. In the Stash panel, Space applies a stash, g pops it, and d drops it.

Keyboard Shortcuts Reference

KeyAction
SpaceStage/unstage file, checkout branch, apply stash
cCommit staged changes
p / PPull / Push
nNew branch
eEdit file, or edit commit (in rebase)
sSquash commit, or stash files
rReword commit message
dDelete branch, drop commit/stash, discard changes
bPick both hunks in merge conflict
TabSwitch between panels
qQuit lazygit
?Show all keybindings for current panel

Press ? in any panel to see the full list of keybindings for that context. Lazygit keybindings are fully customizable through the config file at ~/.config/lazygit/config.yml.

Conclusion

Lazygit makes interactive rebasing, conflict resolution, and branch management significantly faster than typing individual git commands. The ? key is your friend – press it in any panel to discover all available actions. For security auditing of your repositories, check out Gitleaks for scanning git repos for secrets.

Related Articles

Git Install Git on RHEL 10 / Rocky Linux 10 / AlmaLinux 10 Programming Draw Graphs in Linux Terminal with Termgraph macos Install ip / ifconfig commands on macOS Monterey KVM How to use qemu-img & qemu-nbd tools with KVM Images

Leave a Comment

Press ESC to close