当我跑
时git diff FETCH_HEAD
它列出了一大堆预期的更改,因为我从遥控器中获取了更新的版本。
但....
当我跑
时git merge FETCH_HEAD
它告诉我一切都是最新的!!
我哪里错了?
答案 0 :(得分:2)
合并后为什么FETCH_HEAD
与HEAD
不同?
合并会创建一个新提交,其中包含原始HEAD
,现在ORIG_HEAD
和FETCH_HEAD
的所有更改。这意味着,如果您的原始HEAD
包含FETCH_HEAD
中未包含的更改,则新的(合并的)HEAD
将与FETCH_HEAD
不同,因为它也包含这些提交。
要检查
由于上述原因,或者出于其他原因,您当前的分支可能已与之前提取的FETCH_HEAD
保持同步。
要检查此项,请从获取头获取sha
(十六进制数字),如下所示:
git log -1 FETCH_HEAD
commit bec5aadef68a5d29c9d523358a0189b86cad4c82
Author: Alex Brown <alex@XXX>
Date: Tue Nov 16 10:05:19 2010 +0000
weather report
并复制FETCH_HEAD
:bec5aa
接下来,在你头脑的祖先中搜索这个sha
git log HEAD | grep "commit bec5aa" -A 5
commit bec5aadef68a5d29c9d523358a0189b86cad4c82
Author: Alex Brown <alex@XXX>
Date: Tue Nov 16 10:05:19 2010 +0000
weather report
如果返回空白的任何内容,则FETCH_HEAD
已合并。您看到的任何差异都在当前HEAD
中,可能是合并的HEAD
(或后代)。
*演示此“
的示例cd /tmp
mkdir 1
cd 1
git init
echo "Woo" > a.txt
git add a.txt
git commit -m "first commit"
cd ..
git clone 1 2
cd 1
echo "Its nice today" >> a.txt
git commit -a -m "weather report"
cd ..
ls
cd 2
ls
echo "Like peas in a pod" > b.txt
git add b.txt
git commit -m "sayings"
git fetch
git diff FETCH_HEAD
git merge FETCH_HEAD
git diff FETCH_HEAD