Fundamentals 8 min read

Master Lazygit: Quick Install Guide & Essential Commands for Seamless Git Management

This guide introduces Lazygit, an open‑source terminal UI for Git, explains how to install it across macOS, Linux, and Windows using Homebrew, apt, Scoop, and other methods, and walks through its core operations such as staging, committing, pushing, pulling, keybindings, custom commands, and debugging.

macrozheng
macrozheng
macrozheng
Master Lazygit: Quick Install Guide & Essential Commands for Seamless Git Management

Git is a powerful tool, but its many commands can be daunting; Lazygit provides a terminal UI that simplifies Git operations.

Lazygit is an open‑source project maintained by Jesseduffield on GitHub, offering mouse support and other features.

How to Install?

Lazygit provides several installation methods for different platforms.

Homebrew

Tap:

brew install jesseduffield/lazygit/lazygit

Core:

brew install lazygit

Ubuntu (deprecated)

Packages are available via Launchpad PPA.

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

Scoop (Windows)

scoop bucket add extras scoop install lazygit

Fedora and CentOS 7

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

Go

go install github.com/jesseduffield/lazygit@latest

Basic Lazygit Operations

After installation, run

lazygit

inside a local Git repository to open the UI.

You can create an alias, e.g.,

echo "alias lg='lazygit'" >> ~/.zshrc

.

Keybindings

Refer to the keybinding list in the documentation.

Common navigation keys include PgUp/PgDn for scrolling, arrow keys for cursor movement,

x

to open menus, and mouse support for focusing elements.

Add to Staging

Move focus to the Files pane and click a file to stage it; click again to unstage.

Commit

Stage files, press

x

to open the menu, select a commit method, and enter the commit message.

Push

After staging, press

x

, choose Push, and provide the necessary information.

Pull

Open the menu and select Pull to fetch from the remote repository.

Change Directory on Exit

Add the following function to

~/.zshrc

to change the shell directory after exiting Lazygit.

<code>lg() {
    export LAZYGIT_NEW_DIR_FILE=~/.lazygit/newdir

    lazygit "$@"

    if [ -f $LAZYGIT_NEW_DIR_FILE ]; then
        cd "$(cat $LAZYGIT_NEW_DIR_FILE)"
        rm -f $LAZYGIT_NEW_DIR_FILE > /dev/null
    fi
}
</code>

Source the file and use

lg

to launch Lazygit; exiting will switch the directory accordingly.

Undo/Redo

See the documentation for details.

Configuration

Refer to the configuration documentation for customization options.

Custom Commands

If Lazygit lacks a feature, you can implement it via custom commands as described in the docs.

Resolving Merge Conflicts

Interactive Rebasing

Local Debugging

Run

lazygit --debug

in one terminal and

lazygit --logs

in another to view logs side by side.

References

lazygit GitHub repository

Project homepage

Launchpad PPA

Scoop package manager

Copr repository

Keybindings documentation

Undo/Redo documentation

Configuration documentation

Custom commands documentation

cligitInstallationVersion Controlcommandslazygit
macrozheng
Written by

macrozheng

Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.