lazygitの使い方:インストール、基本キー、ステージ・コミット、interactive rebase入門

ターミナル TUI で Git をステージ・コミットし、lazygit で初めて interactive rebase を試す。

数ファイル直すだけなのに should not mean bouncing between git status, git add -p, and another editor. lazygit is a terminal UI for Git: status, staging, commits, branches, and interactive rebase in one place. Upstream repo: github.com/jesseduffield/lazygit.

次を探している人向け: lazygit install keybindings stage commit interactive rebase want: install, learn panels and core keys, stage and commit, and a safe first interactive rebase. Key names follow lazygit’s official Keybindings — press ? in-app to verify your version.

lazygit のインストールPanels & keysStage · commit · rebase intro

lazygit 向いている人

01

git フラグ暗記が面倒な開発者

Navigate with arrows and single keys instead of repeating git add, git restore, git commit.

02

diff を素早く見たい人

Open diffs with Enter, stage files or hunks with Space (panel-dependent).

03

ローカル履歴を整えたい人

Use i in the Commits panel for interactive rebase and edit pick/squash order in the UI.

lazygit のインストール

  1. 1

    macOS: Homebrew

    brew install lazygit, then lazygit --version.

  2. 2

    Windows

    winget install JesseDuffield.lazygit or scoop install lazygit per current package names.

  3. 3

    Linux

    Arch: sudo pacman -S lazygit. Other distros: distro packages, GitHub Releases binaries, or go install github.com/jesseduffield/lazygit@latest with Go installed.

  4. 4

    First launch

    Run lazygit inside a repo root. Outside a repo it errors — cd into a project or git init first.

パネルと基本キー

lazygit splits Status, Files, Branches, Commits, and more. Keys 1–5 often focus panels — confirm with ? on your build.

KeyTypical actionUse case
?Keybinding helpCheck this first
q / EscQuit / backLeave a subview
j / k or arrowsMove selectionList navigation
EnterOpen diff / detailReview changes
SpaceStage / unstageStage file or hunk
cCommitMessage for staged changes
dDiscard (confirm)Drop bad edits
PPushSend to remote
pPullFetch & merge/rebase per config

ステージとコミット

  1. 1

    Open the repo

    cd your-repo && lazygit. Files panel lists modified and untracked paths.

  2. 2

    Read the diff

    Select a file, press Enter for the diff.

  3. 3

    Stage

    Space on a file in the list; for partial stages use hunk actions in the diff/patch view (see help for “stage”).

  4. 4

    Commit

    Press c, type the message, confirm.

  5. 5

    Optional push

    P to push; new branches may prompt for upstream — follow on-screen choices.

cd ~/projects/my-app
lazygit
# Files → Space → c → message → P

interactive rebase 入門

Interactive rebase rewrites local history — squash, reorder, reword. Avoid rebasing shared branches others already built on unless your team allows it.

  1. 1

    Commits panel

    Focus Commits (number keys / Tab) to see branch history.

  2. 2

    Start rebase

    Select the base commit (or use branch actions per docs), press i for interactive rebase. A todo list of pick/squash/fixup appears.

  3. 3

    Edit the todo

    Move the cursor; toggle actions with keys shown in ? (pick, squash, fixup, drop).

  4. 4

    Confirm & fix conflicts

    lazygit runs the rebase. On conflicts, resolve in Files/diff views and continue rebase via menu or keys in help.

  5. 5

    Before push

    Rewritten history may need force-with-lease. lazygit surfaces push options — do not force-push shared mainlines blindly.

Practice on a throwaway branch and git branch backup-before-rebase before your first squash via i.

Align release steps in lazygit; for a shared flow diagram, open a browser room from the wbroom homepage — create and join a room; for terminal multiplexing see tmux guide.

確認しておきたいこと

Does lazygit change git config on its own?

It runs normal git commands. Optional settings live in ~/.config/lazygit/config.yml (path per docs). Remotes change only when you confirm UI actions.

lazygit vs tig vs gitui?

All are terminal Git UIs. lazygit emphasizes keyboard flow, panels, and integrated interactive rebase — pick whichever you keep open.

Does Space stage whole files or hunks?

Often whole files in the file list; hunks in diff/patch views. See Stage entries in ? for your version.

Push rejected after rebase?

Remote still has old commits. If the branch is yours alone, use force-with-lease when offered; if teammates share it, merge or coordinate instead.

会議を始める