Skip to content

Instantly share code, notes, and snippets.

@yano3nora
Last active May 6, 2026 03:26
Show Gist options
  • Select an option

  • Save yano3nora/eb044c9f22559fe29dd491d9cfc4915d to your computer and use it in GitHub Desktop.

Select an option

Save yano3nora/eb044c9f22559fe29dd491d9cfc4915d to your computer and use it in GitHub Desktop.
lazygit - simple terminal UI for git commands

Overview

lazygit
git-delta

lazygit は terminal 上で Git 操作を行うための TUI ツール。

Git コマンドを毎回手で打つより、以下の作業がかなり速くなる。

  • 変更ファイルの確認
  • diff の確認
  • stage / unstage
  • commit
  • branch / stash / log の確認
  • rebase / cherry-pick などの操作

このメモでは、lazygit の導入と、diff を少し見やすくするための git-delta 設定、よく使うショートカットだけをまとめる。

Getting Started

lazygit をインストールする

macOS / Homebrew の場合。

brew install lazygit

起動する。

lazygit

git-delta をインストールする

lazygit の diff 表示を少し見やすくするために、git-delta を入れる。

brew install git-delta

確認。

which delta
delta --version

Setup: diff 表示に git-delta を使う

lazygit を起動して、左上の Status パネルで e を押す。

これで、現在 lazygit が実際に読んでいる config.yml を開ける。

config.yml に以下を追加する。

git:
  paging:
    colorArg: always
    pager: delta --dark --paging=never --side-by-side --line-numbers

設定後、lazygit を一度終了して再起動する。

lazygit

diff が左右比較表示になれば成功。

補足

MacBook の画面幅だと、--side-by-side は読みづらい場合がある。
その場合は --side-by-side を外す。

git:
  paging:
    colorArg: always
    pager: delta --dark --paging=never --line-numbers

より深く設定したい場合は、lazygit / git-delta の公式ドキュメントを見る。

Important Shortcuts

基本操作

key description
? keybindings を表示する
q 現在の画面を閉じる / lazygit を終了する
esc 戻る / popup を閉じる
tab 次の panel に移動する
shift + tab 前の panel に移動する
/ item を移動する
enter 選択中の item を開く / 詳細を見る

ファイル操作

key description
space 選択中の file / hunk / line を stage / unstage する
a 全 file を stage / unstage する
d 選択中の変更を discard する
D より強い discard 系操作を開く
e 選択中の file を editor で開く

d / D は変更を失う操作なので、雑に押さない。

Commit

key description
c commit message を入力して commit する
C commit message を editor で入力して commit する
A amend commit
shift + A amend commit no-edit

amend 系は便利だが、共有済み branch では注意する。

Branch / Checkout

key description
b branch 一覧を開く
space branch を checkout する
n new branch を作る
d branch を delete する

branch panel 上では、space が checkout として使われる。

Stash

key description
s stash する
S stash message を入力して stash する
g stash を apply する
pop stash を pop する操作は stash panel から選ぶ

stash は「一時退避」ではあるが、積みすぎると負債になる。
作業の区切りで branch 化する方が安全なことも多い。

Log / Commit 操作

key description
l commit log を見る
enter commit の詳細を見る
c checkout commit
r reword commit
d drop commit
f fixup commit
s squash commit

reword / drop / fixup / squash は履歴を書き換える。
共有済み branch では慎重に使う。

Pull / Push / Fetch

key description
p pull
P push
f fetch

大文字小文字で操作が違うので注意。

Search / Filter

key description
/ 現在の panel 内を検索する
n 次の検索結果へ移動する
N 前の検索結果へ移動する

ファイル数や commit 数が多い repository ではかなり重要。

My Recommendation

最初に覚えるべきなのは、このあたり。

key description
? 困ったら keybindings を見る
space stage / unstage
a 全 file stage / unstage
c commit
p pull
P push
/ search
e file / config を editor で開く
d discard。ただし慎重に使う

まずは space で必要な差分だけ stage して、c で commit する流れに慣れる。
その後、branch / stash / log 操作を覚えるのが良い。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment