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 向いている人
git フラグ暗記が面倒な開発者
Navigate with arrows and single keys instead of repeating git add, git restore, git commit.
diff を素早く見たい人
Open diffs with Enter, stage files or hunks with Space (panel-dependent).
ローカル履歴を整えたい人
Use i in the Commits panel for interactive rebase and edit pick/squash order in the UI.
lazygit のインストール
- 1
macOS: Homebrew
brew install lazygit, thenlazygit --version. - 2
Windows
winget install JesseDuffield.lazygitorscoop install lazygitper current package names. - 3
Linux
Arch:
sudo pacman -S lazygit. Other distros: distro packages, GitHub Releases binaries, orgo install github.com/jesseduffield/lazygit@latestwith Go installed. - 4
First launch
Run
lazygitinside a repo root. Outside a repo it errors —cdinto a project orgit initfirst.
パネルと基本キー
lazygit splits Status, Files, Branches, Commits, and more. Keys 1–5 often focus panels — confirm with ? on your build.
| Key | Typical action | Use case |
|---|---|---|
? | Keybinding help | Check this first |
q / Esc | Quit / back | Leave a subview |
j / k or arrows | Move selection | List navigation |
Enter | Open diff / detail | Review changes |
Space | Stage / unstage | Stage file or hunk |
c | Commit | Message for staged changes |
d | Discard (confirm) | Drop bad edits |
P | Push | Send to remote |
p | Pull | Fetch & merge/rebase per config |
ステージとコミット
- 1
Open the repo
cd your-repo && lazygit. Files panel lists modified and untracked paths. - 2
Read the diff
Select a file, press
Enterfor the diff. - 3
Stage
Spaceon a file in the list; for partial stages use hunk actions in the diff/patch view (see help for “stage”). - 4
Commit
Press
c, type the message, confirm. - 5
Optional push
Pto push; new branches may prompt for upstream — follow on-screen choices.
cd ~/projects/my-app
lazygit
# Files → Space → c → message → Pinteractive rebase 入門
Interactive rebase rewrites local history — squash, reorder, reword. Avoid rebasing shared branches others already built on unless your team allows it.
- 1
Commits panel
Focus Commits (number keys / Tab) to see branch history.
- 2
Start rebase
Select the base commit (or use branch actions per docs), press
ifor interactive rebase. A todo list of pick/squash/fixup appears. - 3
Edit the todo
Move the cursor; toggle actions with keys shown in
?(pick, squash, fixup, drop). - 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
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-rebasebefore your first squash viai.
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.