0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Git】ハンク操作入力キーまとめ

0
Posted at

git add -pgit 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
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?