Lazygit
1. Basics
Panel Navigation
-
← / → (Left/Right Arrow Keys): Navigate between panels in this order:
- Status panel
- Files panel (changed, created, or deleted files)
- Branches panel
- Commits panel
- Stash panel
-
Tab / Shift+Tab: Same as above arrows
Pushing / Pulling
- p: invokes a
git pull. - Shift+P: invokes a
git push- When git identifies a divergence, it opens a confirmation box asking whether to
push --forceor cancel the operation.
- When git identifies a divergence, it opens a confirmation box asking whether to
Command Prompt
- :: Opens a command prompt that allows for quickly executing shell commands without having to quit lazygit or switch to a different terminal
Help Menu
- ?: Opens a menu with all available keybindings and actions. The menu is context-specific, and changes based on the current active panel.
2. Files Panel
Basic File Staging
- Space: Toggle staging/unstaging of the selected file
- a: Toggle between staging all files or resetting all files
Committing Changes
- c: Open the commit message editor to write your commit message
Discarding Changes
- d: Discard changes on the selected file (shows confirmation box)
- Shift+D: Open a menu with multiple discard options
- Nuke working tree: Clears all changes and deletes all new files (most commonly used)
Viewing File Changes
- Enter: Navigate to the split view showing file changes
- Left side: unstaged changes
- Right side: staged changes
Stashing Changes
- s: Stash changes. Asks for confirmation and an optional name for the stash.
- Shift+S: Opens a stash options menu where you can choose to stash only staged changes.
3. Files --> Diff View Sub-Panel
When you press Enter on a file, you enter the diff view where you can stage individual lines or hunks.
Staging Modes
- a: Toggle between two staging modes:
- Hunk mode: Stage entire hunks (like VS Code's diff viewer)
- Line mode: Stage individual lines
- Space: Add or remove the current line/hunk (toggles between staged/unstaged)
Range Selection
- v: Start selecting a range of lines
- ↑ / ↓ (Arrow Keys Up/Down): Extend the selection range
- Space: Stage or unstage the selected range
Navigation Between Panes
- Tab: Switch from the left pane (unstaged) to the right pane (staged)
Removing Changes
- d (left pane): Delete the line/change
- d (right pane): Unstage the change
4. Branches Panel
Switching Branches
- Space (on a branch): Check out to that branch
Fetching a Branch
- f (on a branch): Fetch the selected branch
Rebasing
- r (on a branch): Rebase the current branch (marked with
*) onto the selected branch
Creating Pull Requests
- o: Create a pull request from the currently selected branch
- The pull request will target the default branch (e.g.,
mainormaster)
- The pull request will target the default branch (e.g.,
- Shift+O: Create a pull request with a target branch selection
- Opens a searchable dropdown allowing you to choose which branch to merge into
5. Commits Panel
Viewing Commit Files
- Enter (on a commit): View the actual files that were involved in that commit. By hitting Esc, you can go back to the list of commits.
Resetting to a Commit
- g (on a commit): Reset to that commit. Opens a menu asking what to do with the changes between HEAD and that commit (discard them or keep them).
Cherry Picking
- Navigate to the Commits panel
- v: Start range selection mode
- ↑ / ↓ (Arrow Keys Up/Down): Extend the range to select multiple commits
- Shift+C: Copy the selected commit hashes
- Navigate to the Branches panel
- Space: Check out to the target branch
- Shift+V: Paste and apply the copied commits (cherry pick)
Amending Commits
- Make changes to your file(s)
- Navigate to the Commits panel
- Select the last commit (the one you want to amend)
- Shift+A: Request to amend the commit with your changes
- Enter: Confirm and apply the amendment
Squashing Commits
- s (on a commit): Squash the commit with the commit below it. Asks for confirmation before executing.
Reverting Commits
- t (on a commit): Revert that commit. Asks for confirmation before execution.
Moving Code Between Commits
To move specific changes from one commit to another:
- Select a commit and press Enter on a file to view all changes made to that file
- Use Space to extract specific diffs and create a "custom patch" (visible on the right side)
- Press Esc twice to return to the commits list
- Navigate to the target commit where you want to move the patch
- Press Ctrl+P to open the patch menu
- Select "move the patch into the selected commit"
6. Quick Reference Table
| Key | Context | Action |
|---|---|---|
| ← → | Any panel | Navigate between panels |
| Space | Files panel | Toggle file staging |
| Space | Diff view | Stage/unstage line or hunk |
| Space | Branches panel | Check out branch |
| a | Files panel | Toggle stage/unstage all files |
| a | Diff view | Toggle hunk/line mode |
| c | Files panel | Open commit message editor |
| d | Files panel | Discard file changes |
| d | Diff view (left) | Delete line |
| d | Diff view (right) | Unstage change |
| Shift+D | Files panel | Open discard menu |
| Enter | Files panel | View file diff |
| Tab | Diff view | Switch between unstaged/staged panes |
| v | Diff view | Start range selection |
| v | Commits panel | Start commit range selection |
| Shift+C | Commits panel | Copy selected commits |
| Shift+V | Commits panel | Paste/cherry-pick commits |
| Shift+A | Commits panel | Amend commit |