这是我在尝试比较分支和主文件之间的文件时得到的结果:
git diff gamemodes/terrortown/entities/entities/ttt_c4/shared.lua
master:gamemodes/terrortown/entities/entities/ttt_c4/shared.lua
fatal: Path 'gamemodes/terrortown/entities/entities/ttt_c4/shared.lua'
exists on disk, but not in 'master'.
这是master上的文件:
$ git log -n 1 -- gamemodes/terrortown/entities/entities/ttt_c4/shared.lua
commit d0241471298ce617b68dcf268be1c0af0cf8170c
Author: me
Date: Fri Jan 1 23:25:17 2016 -0600
December 2015 Update
这是我的分支上的文件real_disarm:
$ git log -n 1 -- gamemodes/terrortown/entities/entities/ttt_c4/shared.lua
commit 84a7de46b92b8747cf98a57a8f7101682377980e
Author: me
Date: Sun Jan 10 00:27:33 2016 -0600
Remove trailing whitespace
显然,该文件存在于两个分支中。我正在比较文件的全部原因是因为我正在尝试删除尾随空格,以便我的补丁不会产生恼人的“警告:压制5个空白错误警告:10行添加空白错误。”输出
答案 0 :(得分:1)
您可以在“How can I compare files from two different branches?”中找到将文件与其他分支进行比较的不同方法。
在你的情况下:
git diff ..master -- gamemodes/terrortown/entities/entities/ttt_c4/shared.lua
请参阅Mark Longair关于“What are the differences between double-dot “..” and triple-dot “…” in git diff
commit ranges?”
..master
将显示当前分支(HEAD
)和master
的提示之间的差异。