LoginSignup
1
0

More than 1 year has passed since last update.

Git操作 備忘録

Posted at

以前使用しましたが、忘れそうだったので記事を書きます
自分用なので間違っている可能性があります 実際に使用する際は調べてから使用してください

git add -u

以前のcommitで追加されたファイルであり、かつ今回更新されたファイルのみがステージングされる

git restore [filename]

特定のファイルを以前のcommitの状態に戻す
git restore . だとカレントディレクトリが全部戻る

-s オプションをつけてコミット番号を指定するとそのバージョンに戻せる

git reset [—soft|—mixed|—hard] [commitの指定]

[commitの指定]フィールドで指定された段階のcommitを取り消す
—soft commitを取り消す
—mixed addとcommitを取り消す
—hard addとcommitを取り消してファイルの中身も巻き戻す

[commitの指定]フィールドの記法
HEADに加えて^を巻き戻したいcommitの数だけ

Ex) 2つ前のcommitに巻き戻したいけど、ファイルは巻き戻さない場合
Git reset —mixed HEAD^^

1
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
1
0