LoginSignup
14
10

More than 5 years have passed since last update.

git reset -p で git add -p をリセットする

Posted at

それ git reset --patch でできるよ。

   git reset (--patch | -p) [<commit>] [--] [<paths>...]
       Interactively select hunks in the difference between the index and <commit> (defaults to
       HEAD). The chosen hunks are applied in reverse to the index.

       This means that git reset -p is the opposite of git add -p, i.e. you can use it to
       selectively reset hunks. See the `Interactive Mode'' section of linkgit:git-add[1] to
       learn how to operate the `--patch mode.

git add しすぎた状態。下の方の差分はまだコミットしたくないのでインデックスから取り除きたい。

そこでおもむろに git reset -p とすると、 git add -p と同じ感じになるので同じ感じに操作するとインデックスから取り除ける。要するに git add -p の真逆のことができる。

便利ですね!!

14
10
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
14
10