LoginSignup
1
1

More than 1 year has passed since last update.

git diffのチートシート

Last updated at Posted at 2023-04-29

一挙動ごとに確認をすることが大切

状態 コマンド 補足
ファイル比較 git diff -- ファイルパスA ファイルパスB いつでも可能
変更内容すべて git diff git add前
特定ファイルの変更内容 git diff -- 対象のファイルパス git add前
git add後、commit前 git diff --cached 参考:git add取り消し → git rm --cached [ファイル名]
git commit後 git diff HEAD^ 本来は git diff HEAD^..HEAD と書くのが正しい。.. の右側を省略すると暗示的に現在のブランチのHEADを示す
git push する前にリモートとの変更点を見る git diff リモート名/ブランチ名..HEAD .. の右側が時系列的に最新とみなされるので、この場合は git commit した後にリモートリポジトリと、これから push したい箇所を表示したい場合の意味
オプション 意味
--output=ファイル名 stdoutではなくファイルに結果を出力
1
1
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
1