TL;DR: lazygit replaces commands like git add -p or git reset --mixed with a TUI.

The Modern CLI Stack book shows installing lazygit and points you at ? for the help screen. That is enough to discover the tool, not to use it. Here are three workflows where it pays off in everyday git work.

1. Stage hunks, not files

You changed four things. You want to commit two of them. In plain git, the answer is git add -p, which walks you through each chunk and asks you to stage or skip it. It works. But there is no live preview of what the staged result will look like.

In lazygit:

  1. Press enter on the file in the Files panel to open the staging view.

  2. Press space to toggle each line you want staged (lines move to the right pane).

  3. Press <esc> to return to the files panel — the selection is saved and applied to your staged changes.

  4. The file is now staged with exactly the lines you selected. You can then press c and you will be able to commit, providing your commit message in the confirmation prompt.

The reason this is faster than git add -p is not the keystrokes. It is the visual feedback: unstaged diff on the left, staged diff on the right, toggle lines until the right side looks like the commit you want.

This wins when: the diff has lines from more than one logical change and you want to commit only some.

2. Undo the last commit

You committed too early.

For undoing the commit, in plain git, you use one of three reset modes against HEAD~1 (the commit just before HEAD):

  • git reset --soft HEAD~1 — undoes the commit and keeps your changes staged.

  • git reset --mixed HEAD~1 — undoes the commit and leaves your changes as uncommitted edits in your files.

  • git reset --hard HEAD~1 — undoes the commit and discards the changes entirely.

A typo in the ~1 part points at the wrong commit, and --hard on the wrong branch loses work done.

In lazygit:

  1. Open the commits panel: from the side bar, press <right> (or l) until the highlight lands on commits.

  2. To undo the commit: press z. lazygit walks the reflog and prompts to soft-reset to the parent of that commit.

  3. To pick the mode explicitly (soft, mixed, or hard), select the target commit, then press g for the menu.

z and g both show a confirmation prompt before they run; the git command does not fire until you press enter on it.

This wins when: you committed too early and want to rewrite the message before pushing.

3. Merge a branch

Your feature branch is ready. Your main branch has evolved. In plain git, the move is git checkout main && git merge <branch> (or git merge <branch> from the feature branch, depending on which direction you want the merge commit to point). Then you watch the output, deal with whatever happens, and switch back to your editor. The switch is the cost: three terminal round-trips for one logical operation.

In lazygit:

  1. From the side bar, press <right> (or l) to cycle to the branches panel.

  2. Move to the branch you want to merge in (the source).

  3. Press M to open the merge options menu.

  4. Pick the option you want; lazygit runs the merge and reports the result.

The win is that you do not leave the TUI between "look at the branches" and "merge is done." If the merge is clean, you stay in the branches panel and the new commit is there.

This wins when: you are about to merge one local branch into another and want the option set in front of you before committing to the operation.

Try it

Run brew install lazygit or apt install lazygit. Open any git repo. Press ? to see the full keymap. The three workflows above are the daily ones; the rest of the keymap is for occasional operations (cherry-pick, rebase interactive, bisect) that you can look up when you need them.

One CLI trick

# Stage hunks for the file you are about to commit
# (lazygit's Files-panel <enter> on a file, in plain git terms)
git diff --staged  # preview what is staged
git add -p         # lazygit replaces this

git add -p is one workflow lazygit replaces. If you have never tried it, run it on any dirty repo before using lazygit.

Reply

Avatar

or to participate