Lazygit

From G1Joshi/Agent-Skills · View interactive version

Lazygit is an AI agent skill from the GitHub repository G1Joshi/Agent-Skills. Expert Lazygit terminal UI assistance covering git staging, interactive rebasing, branch management, cherry-picking, and diff inspection. Use when managing Git repositories with keyboard speed.

How to use this skill

Skill file

Lazygit

Lazygit is a TUI for Git. It makes complex operations (interactive rebase, partial staging) accessible via intuitive keyboard shortcuts.

When to Use

Quick Start

# Launch lazygit inside any Git repository
lazygit

# Key Navigation:
# 1, 2, 3, 4, 5: Jump between Files, Branches, Commits, Stash panels
# Space: Stage/unstage selected file or hunk
# c: Commit staged changes
# P: Push to upstream
# p: Pull from upstream
# r: Interactive rebase on selected commit

Core Concepts

Core Keybindings & Panel Navigation

Navigating git repository state with single keystrokes:

Interactive Rebase & Commit Squashing

Streamlining commit histories visually:

  1. Press 4 to navigate to the Commits panel.
  2. Highlight the base commit before your branch changes.
  3. Press i to start an interactive rebase.
  4. Highlight commits to modify:
  1. Press m to open merge / rebase options.

Custom Commands Configuration (config.yml)

Adding customized workflows to Lazygit:

# ~/.config/lazygit/config.yml
gui:
  theme:
    selectedLineBgColor:
      - reverse
  nerdFontsVersion: "3"

customCommands:
  - key: "P"
    command: "git push --force-with-lease origin {{.SelectedLocalBranch.Name}}"
    context: "localBranches"
    description: "Force push with lease safely"
    prompts:
      - type: "confirm"
        title: "Force Push"
        body: "Are you sure you want to force push with lease?"

Common Patterns

Custom Lazygit Commands

Problem: Need one-key git workflow actions (e.g. git standup, prune remote branches).

Solution: Define custom keybindings in ~/.config/lazygit/config.yml.

# ~/.config/lazygit/config.yml
customCommands:
  - key: "P"
    command: "git remote prune origin"
    context: "remotes"
    loadingText: "Pruning stale branches..."
  - key: "b"
    command: 'git branch --merged | grep -v "\*" | xargs -n 1 git branch -d'
    context: "branches"
    prompts:
      - type: "confirm"
        title: "Delete Merged Branches"
        body: "Are you sure you want to delete all merged local branches?"

Best Practices

Do:

Don't:

Troubleshooting

| Error | Cause | Solution |

| :----------------------------------- | :------------------------------------------------------------ | :------------------------------------------------------------------------------------------ |

| lazygit: command not found | Binary not installed in system PATH. | Install via brew install lazygit or Linux package manager. |

| Rebase conflict screen in Lazygit | Interactive rebase paused due to merge conflict. | Resolve conflicting files, stage with Space, and press m to choose "Continue rebase". |

| Cannot push: credentials not found | Git credential helper not configured in terminal environment. | Configure credential cache: git config --global credential.helper osxkeychain (or store). |

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.