2010-11-16 41 views
3

当我运行git的差异让我比git的不同反馈合并

git diff FETCH_HEAD 

它列出的预期变化的负载,因为我拿来从我的远程更新的版本。

但....

当我运行

git merge FETCH_HEAD 

它告诉我一切是最新的!

我哪里错了?

+1

你有不分阶段的变化?请'混帐status'。并尝试'git的差异HEAD FETCH_HEAD',以避免与当前工作树进行比较。 – 2010-11-16 09:58:11

+0

没有提交,并且git diff HEAD FETCH_HEAD仍然给我很大的区别 – 2010-11-16 10:01:30

回答

2

为什么FETCH_HEADHEAD不同?合并后?

合并创建了一个新的提交,包含所有从原来的HEAD,现在ORIG_HEADFETCH_HEAD的变化。这意味着如果您的原始HEAD包含的变更未包含在FETCH_HEAD中,则新的(合并的)HEAD将与FETCH_HEAD不同,因为它也包含这些提交。

事情检查

这可能是您当前分支已经启动最新与FETCH_HEAD从以前的获取,由于上述原因,或因其他原因。

要从取头检查这一点,得到了sha(十六进制数),如下所示:

git log -1 FETCH_HEAD 
commit bec5aadef68a5d29c9d523358a0189b86cad4c82 
Author: Alex Brown <[email protected]> 
Date: Tue Nov 16 10:05:19 2010 +0000 

    weather report 

和复制的第一个6个位数的FETCH_HEADbec5aa

未来,搜索这个sha在你的头上

git log HEAD | grep "commit bec5aa" -A 5 

commit bec5aadef68a5d29c9d523358a0189b86cad4c82 
Author: Alex Brown <[email protected]> 
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 
+0

那么你的意思是我的本地HEAD实际上超过了我的远程FETCH_HEAD? – 2010-11-16 10:24:58

+1

要检查你的'FETCH_HEAD'是否已经包含在'HEAD'中,你可以调用'git log HEAD..FETCH_HEAD',这将显示'FETCH_HEAD'中的所有提交都没有包含在'HEAD'中,如果输出为空,则没有任何合并。使用像gitk这样的图形工具。 – 2010-11-16 10:38:26

+0

@MildFuzz - 这是你所看到的一种可能的解释。 – 2010-11-16 10:43:31