LazyGit is a terminal UI for Git that makes staging, committing, branching, and rebasing visual and fast. If you've ever fumbled with git add -p or struggled with interactive rebase, LazyGit makes those operations point-and-click.
This guide covers the full LazyGit workflow: from installation to custom commands and rebase mastery.
Install LazyGit:
brew install lazygitlg as a shell aliasAdd an alias for convenience:
# ~/.zshrc or ~/.bashrc
alias lg='lazygit'Run lg in any Git repository. The interface has five panels: Status, Files, Branches, Commits, and Stash. Navigate with H/J/K/L (vim-style) or arrow keys.
Space — stage/unstage a file or hunka — stage/unstage all filesc — commit (opens editor for message)Enter — view file diff or commit detailsTab — switch between panels+ / - — expand/collapse diff hunksThe bottom bar always shows context-appropriate keybindings. You don't need to memorize everything — just look down.
LazyGit's killer feature is line-level staging. In the Files panel, select a file, press Enter to see the diff, then:
Space on a specific hunk — stage just that hunkarrow down to select individual lines, then Space — stage just those linesd — delete uncommitted changes (with confirmation)S — stash changesshift+S — pop the latest stashe on a selected hunk to edit it in your $EDITOR before staging. Perfect for quick fixes mid-staging.LazyGit can be extended with custom commands. In ~/.config/lazygit/config.yml:
customCommands:
- key: 'C'
command: "git commit --amend --no-edit"
context: 'files'
description: 'Amend commit without editing message'
- key: 'P'
command: "git push --force-with-lease"
context: 'commits'
description: 'Force push with lease (safe)'
- key: 'f'
command: "git fetch --prune"
context: 'localBranches'
description: 'Fetch and prune remote branches'{{.SelectedFile.Name}} to pass context to your commandCommon issues and fixes:
gui: mouseEvents: true in config.yml$EDITOR or $GIT_EDITOR is setctrl-z or run git rebase --abort outside LazyGitYou've mastered LazyGit basics. Go deeper: