2011-05-11 124 views
1

我正在贡献LibreOffice并已开始学习git。我克隆了LibreOffice存储库并获得了成功构建。 LibreOffice有19个git存储库,名为引导程序,并保留在一个较低的层次上,分别命名为writer,calc,postprocess和base等。它有一个脚本,名称为g,用于在所有存储库中同时运行git命令,而不是单独运行。git为什么警告我我的分支已经与主人分离了?

克隆后,我创建了一个在远程仓库中推送的补丁。此时我的所有更改都已经完成(即git diff不输出任何内容),状态是我是主分支前的提交。

现在,当我运行./g pull -r我得到这个输出:

[email protected]:~/git/libo$ ./g pull -r 
===== main repo ===== 
Current branch master is up to date. 
===== artwork ===== 
Current branch master is up to date. 
===== base ===== 
Current branch master is up to date. 
===== calc ===== 
Current branch master is up to date. 
===== components ===== 
Current branch master is up to date. 
===== extensions ===== 
Current branch master is up to date. 
===== extras ===== 
Current branch master is up to date. 
===== filters ===== 
Current branch master is up to date. 
===== help ===== 
Current branch master is up to date. 
===== impress ===== 
Current branch master is up to date. 
===== libs-core ===== 
Current branch master is up to date. 
===== libs-extern ===== 
Current branch master is up to date. 
===== libs-extern-sys ===== 
Current branch master is up to date. 
===== libs-gui ===== 
From http://anongit.freedesktop.org/git/libreoffice/libs-gui 
    08137a2..d314277 master  -> origin/master 
First, rewinding head to replay your work on top of it... 
Fast-forwarded master to d3142771895c2e9ce029e3b52af7f1ea1b437a6b. 
===== postprocess ===== 
Current branch master is up to date. 
===== sdk ===== 
Current branch master is up to date. 
===== testing ===== 
Current branch master is up to date. 
===== ure ===== 
Current branch master is up to date. 
===== writer ===== 
U sw/source/core/doc/docdesc.cxx 
U sw/source/core/frmedt/fews.cxx 
M sw/source/core/inc/SwXMLBlockExport.hxx 
U sw/source/core/inc/UndoCore.hxx 
U sw/source/core/inc/ascharanchoredobjectposition.hxx 
U sw/source/core/inc/frame.hxx 
Pull is not possible because you have unmerged files. 
Please, fix them up in the work tree, and then use 'git add/rm <file>' 
as appropriate to mark resolution, or use 'git commit -a'. 

这说明一些问题写模块中的一些文件(SW)和提到的文件是一些从补丁所使用的那些我贡献。

git diff表明这一点:

[email protected]:~/git/libo$ cd sw 
[email protected]:~/git/libo/sw$ git diff 
diff --cc sw/source/core/doc/docdesc.cxx 
index 0900b18,52b984e..0000000 
--- a/sw/source/core/doc/docdesc.cxx 
+++ b/sw/source/core/doc/docdesc.cxx 
@@@ -216,7 -216,7 +216,11 @@@ void SwDoc::ChgPageDesc(sal_uInt16 i, 
     if(rChged.GetNumType().GetNumberingType() != pDesc->GetNumType().GetNumbe 
     { 
      pDesc->SetNumType(rChged.GetNumType()); 
++<<<<<<< HEAD 
+  // den Seitennummernfeldern bescheid sagen, 
++======= 
+   // Bug 64121 - den Seitennummernfeldern bescheid sagen, 
++>>>>>>> Removal of bogus comments in writer module 
      //   das sich das Num-Format geaendert hat 
      GetSysFldType(RES_PAGENUMBERFLD)->UpdateFlds(); 
      GetSysFldType(RES_REFPAGEGETFLD)->UpdateFlds(); 
diff --cc sw/source/core/frmedt/fews.cxx 
index 6fe4bf0,4dc82ff..0000000 
--- a/sw/source/core/frmedt/fews.cxx 
+++ b/sw/source/core/frmedt/fews.cxx 
@@@ -1266,6 -1267,7 +1266,10 @@@ Size SwFEShell::GetGraphicDefaultSize(
     return aRet; 
    } 

++<<<<<<< HEAD 
++======= 
+ // add output parameter <bVertL2R> 
++>>>>>>> Removal of bogus comments in writer module 
    sal_Bool SwFEShell::IsFrmVertical(const sal_Bool bEnvironment, sal_Bool& bRTL, 
    { 
     sal_Bool bVert = sal_False; 
diff --cc sw/source/core/inc/UndoCore.hxx 
index e8fda05,99f4722..0000000 
--- a/sw/source/core/inc/UndoCore.hxx 
+++ b/sw/source/core/inc/UndoCore.hxx 
@@@ -133,6 -133,7 +133,10 @@@ class SwUndoFmtColl : public SwUndo, pr 
     void DoSetFmtColl(SwDoc & rDoc, SwPaM & rPaM); 

    public: 
++<<<<<<< HEAD 
++======= 
+ // SwUndoFmtColl(const SwPaM&, SwFmtColl*); 
++>>>>>>> Removal of bogus comments in writer module 
     SwUndoFmtColl(const SwPaM&, SwFmtColl*, 
        const bool bReset, 
        const bool bResetListAttrs); 
@@@ -202,6 -203,7 +206,10 @@@ public 
     virtual void RepeatImpl(::sw::RepeatContext &); 
    }; 

++<<<<<<< HEAD 
++======= 
+ //-------------------------------------------------------------------- 
++>>>>>>> Removal of bogus comments in writer module 

    const int nUndoStringLength = 20; 

diff --cc sw/source/core/inc/ascharanchoredobjectposition.hxx 
index 16dde41,2f868a9..0000000 
--- a/sw/source/core/inc/ascharanchoredobjectposition.hxx 
+++ b/sw/source/core/inc/ascharanchoredobjectposition.hxx 
@@@ -140,7 -140,7 +140,11 @@@ namespace objectpositionin 
       Point GetAnchorPos() const; 

      // calculated relative position to base line for object position ty 
++<<<<<<< HEAD 
+ 
++======= 
+    
++>>>>>>> Removal of bogus comments in writer module 
       SwTwips GetRelPosY() const; 

      // determined object rectangle including spacing for object position 
diff --cc sw/source/core/inc/frame.hxx 
index 664f28b,94db9cc..0000000 
--- a/sw/source/core/inc/frame.hxx 
+++ b/sw/source/core/inc/frame.hxx 
@@@ -248,6 -250,9 +248,12 @@@ enum MakePageTyp 
     MAKEPAGE_NOSECTION  // Don't create section frames 
    }; 

++<<<<<<< HEAD 
++======= 
+ // #i28701# - replaced by new class <SwSortedObjs> 
+ //typedef SdrObject* SdrObjectPtr; 
+ //SV_DECL_PTRARR(SwDrawObjs,SdrObjectPtr,1,1); 
++>>>>>>> Removal of bogus comments in writer module 

    class SwFrm: public SwClient, public SfxBroadcaster 
    { 
(END) 

git status表明这一点:

[email protected]:~/git/libo/clone/writer$ git status 
# Not currently on any branch. 
# Changes to be committed: 
# (use "git reset HEAD <file>..." to unstage) 
# 
# modified: sw/source/core/inc/SwXMLBlockExport.hxx 
# 
# Unmerged paths: 
# (use "git reset HEAD <file>..." to unstage) 
# (use "git add/rm <file>..." as appropriate to mark resolution) 
# 
# both modified:  sw/source/core/doc/docdesc.cxx 
# both modified:  sw/source/core/frmedt/fews.cxx 
# both modified:  sw/source/core/inc/UndoCore.hxx 
# both modified:  sw/source/core/inc/ascharanchoredobjectposition.hxx 
# both modified:  sw/source/core/inc/frame.hxx 
# 
# Untracked files: 
# (use "git add <file>..." to include in what will be committed) 
# 
# 0001-Removal-of-bogus-comments-in-writer-module.patch 

如果我试图通过手动编辑这些文件来解决冲突,Git会告诉我,我的主人已经从产地分歧/主。这种情况持续一个周期。请帮助我。问题是什么,我该如何解决?

+1

爱得要死!几乎从来没有完全不可能使用! – korona 2011-05-11 09:20:14

+1

你不在一个分支,顺便说一句。 – Abizern 2011-05-11 09:35:19

+2

这不是IRC。请将此代码片段粘贴到此处,而不是粘贴在pastebin上。上帝知道他们存档多久。 – 2011-05-11 09:36:13

回答

1

为什么git警告我说我的分支已经和主人分道扬?了?

Git警告你,你的分支已经与主分离,因为你的分支已经与主分离。

如果我正确理解了这种情况,首先在master(我们称之为A)之上创建了一个新的提交(我们称它为B)。 Git正确地说,你提前originmaster

A---B 

同时,其他人加在origin上的新提交的master

A---B 
\ 
    C---D---E 

在这一点上,你masteroriginmaster有分歧。您有一个origin/master没有的提交,并且origin/master有3个您没有的提交。其中一个3甚至可能是您发送的补丁(我在您的git status输出中看到git format-patch创建的文件,所以我猜你已将它作为补丁发送);应用补丁不会创建完全相同的提交(至少提交者名称和时间戳会不同)。

当你做一个git pull,Git有合并的提交(B)你没有提交,创建一个合并提交(我们称之为F):

A---B-------F 
\  /
    C---D---E 

再次注意, origin/master没有提交(BF这次)。如果有人向origin/master添加新提交,则必须重新合并。

现在,如何摆脱这种情况?有几种方法。一种是将你的改变推到origin,所以现在它拥有你所拥有的一切。另一个是放弃您的提交并将您的master重置为origin/master。第三个是在origin/master之上重新提交您的提交。

如果我猜对了您通过git format-patch通过电子邮件发送了您的更改并且已经应用​​了这些更改,那么在您的案例中,最佳解决方案是将master重置为origin/master。为避免将来出现此问题,最好在单独的分支中工作,并切换回master,然后再从上游进行更改。

+0

谢谢..其实问题是,提交者在我的补丁中做了一个小改动,并且因为它与我的提交不同,所以在我的结束时创建了一个问题。感谢这样一个有指导的答案。我也跟着讲过同样的道路。 :) – 2011-06-14 05:48:58

相关问题