git add -pやgit restore -p などで、以下のような出力出てきますよね。
- a
+ b
(1/3) Unstage this hunk [y,n,q,a,d,j,J,g,/,s,e,p,?]?
なんだかんだ y, n, a, dしか活用してなくて、他のキー内容が気になったのでまとめてみました。
基本操作(y/n)
-
y: このハンクを適用する -
n: このハンクをスキップする -
q: 終了(残りは全てスキップ) -
a: このハンク以降、ファイル内の残り全部を適用する -
d: このハンク以降、ファイル内の残り全部をスキップする(次のファイルへ)
ハンクを分割・編集
-
s: ハンクをもっと小さく分割する(split) -
e: ハンクを手動編集する(エディタが開く)
移動
-
g: 特定のハンクにジャンプ(select a hunk to go to) -
/: 正規表現でハンクを検索 -
j: 次の未決定ハンクへ進む(このハンクは保留) -
J: 次のハンクへ進む(このハンクは保留) -
k: 前の未決定ハンクへ戻る(このハンクは保留) -
K: 前のハンクへ戻る(このハンクは保留)
ヘルプキー
?を入力すると一通り内容が出てきます。
y - unstage this hunk
n - do not unstage this hunk
q - quit; do not unstage this hunk or any of the remaining ones
a - unstage this hunk and all later hunks in the file
d - do not unstage this hunk or any of the later hunks in the file
j - leave this hunk undecided, see next undecided hunk
J - leave this hunk undecided, see next hunk
g - select a hunk to go to
/ - search for a hunk matching the given regex
s - split the current hunk into smaller hunks
e - manually edit the current hunk
p - print the current hunk, 'P' to use the pager
? - print help