Getting started with lazygit

ยทcheatly.dev
lazygit staging and commit demo
Staging files, committing โ€” the everyday lazygit workflow

Git is powerful. Git is also, let's be honest, kind of hostile. Even experienced developers sometimes stare at a merge conflict wondering if they should just rm -rf the repo and start over. The CLI works, but it demands that you hold a mental model of branches, staging areas, commit graphs, and reflog history all in your head at once.

lazygit takes that mental model and puts it on screen. It's a terminal UI for git created by Jesse Duffield โ€” not a replacement for the git CLI, but a visual layer on top of it that makes the common workflows dramatically faster and less error-prone. If you're comfortable in the terminal but tired of typing git log --oneline --graph to figure out where you are, lazygit might be the best tool you install this year.

Installing it

lazygit is available through all the usual package managers:

Once installed, cd into any git repo and type lazygit. That's it. No config needed.

The panel layout

When lazygit opens, you'll see the screen divided into panels. This is the core mental model โ€” everything in lazygit happens within one of these panels.

The left side has a stack of narrow panels: Status (current branch info), Files (your working tree changes), Branches (local and remote), Commits (the log for your current branch), and Stash. The right side is a large preview pane that shows you the diff, commit details, or whatever is contextually relevant to your current selection.

You switch between panels with the number keys 1 through 5, or cycle through them with Tab. Inside any panel, you move up and down with j and k (or arrow keys). The preview pane updates as you navigate โ€” select a file and you see its diff, select a commit and you see what changed.

Press ? in any panel to see every shortcut available in that context. This is your safety net while learning. You don't need to memorize anything โ€” just know that ? always has the answer.

The staging workflow

This is where lazygit earns its keep. The staging workflow replaces what is usually a tedious cycle of git status, git diff, git add, squint at the output, repeat.

Staging & Files
Space
Stage or unstage the selected file
a
Stage or unstage all files
Enter
Open a file to stage individual hunks or lines
d
Discard changes in the selected file
e
Open the file in your editor

The real power is in hunk staging. Press Enter on a file and you'll see its diff broken into hunks. Press Space to stage individual hunks, or use Tab to switch between staged and unstaged views. If you need even finer control, you can stage individual lines. This is what git add -p wishes it could be โ€” the same functionality but with a real visual interface instead of a y/n prompt loop.

Making commits

Once your changes are staged, committing is straightforward:

Commits
c
Commit staged changes (opens a message input)
C
Commit with your $EDITOR for longer messages
A
Amend the last commit with currently staged changes
r
Reword a commit message (in the Commits panel)
s
Squash the selected commit into its parent
f
Fixup โ€” squash and discard the commit message

Press c, type your message, hit Enter, done. No git commit -m quoting gymnastics. If you realize you made a typo in your last commit message, jump to the Commits panel, select it, and press r to reword. This kind of quick correction used to mean remembering git commit --amend or git rebase -i โ€” in lazygit, it's a single keystroke.

Working with branches

The Branches panel (3) shows your local branches, remote branches, and tags in separate tabs. Switch between tabs with [ and ].

Branches
Space
Checkout the selected branch
n
Create a new branch
M
Merge selected branch into current
r
Rebase current branch onto selected
d
Delete the selected branch

Switching branches is just navigating to the one you want and pressing Space. If you have uncommitted changes, lazygit will warn you and offer to stash them โ€” no surprise errors, no lost work.

Interactive rebase (the killer feature)

This is where lazygit genuinely shines. Interactive rebasing in the CLI means running git rebase -i, staring at a list of commits in your editor, changing pick to squash or reword, saving, and hoping you didn't mess up the order. In lazygit, you do it all visually.

Navigate to the Commits panel, and you can reorder commits by moving them with Ctrl-j and Ctrl-k. Squash with s, fixup with f, drop with d, reword with r. You see the result immediately in the commit list. If something goes wrong, z undoes the last action โ€” lazygit keeps its own undo history on top of git's reflog.

The undo feature (z) is a lifesaver when you're learning. Accidentally dropped a commit? Undo. Squashed the wrong thing? Undo. It gives you permission to experiment without fear, which is exactly what you need when learning git operations that feel destructive.

When to drop back to the CLI

lazygit handles the daily workflow brilliantly, but it's not a complete replacement for the git CLI. A few situations where you'll want to drop back:

You can press e to open files in your editor directly from lazygit, and you can drop to a shell without leaving the UI. The two workflows complement each other.

Getting comfortable

The best way to learn lazygit is to open it in a real repo you're working on and just use it. Don't try to memorize shortcuts โ€” let ? be your guide for the first week. You'll naturally remember the keys you use most often, and the rest will come as you need them.

For a complete shortcut reference, check out our lazygit cheatsheet. The official lazygit wiki has detailed guides on specific workflows, and Jesse Duffield's YouTube demos are worth watching to see how a power user moves through the interface.

Git doesn't have to be painful. Give lazygit a week, and the only painful part will be wondering why you didn't try it sooner.