簡體   English   中英

為什么git會警告我我的分支與主分支不同?

[英]Why does git warn me that my branch has diverged from master?

我正在為LibreOffice做貢獻,並且已經開始學習git。 我已經克隆了LibreOffice存儲庫並成功構建。 LibreOffice有19個git存儲庫1(稱為引導程序),並保留在較低一級,分別稱為writer,calc,postprocess,base等。它具有一個腳本供g以便在所有存儲庫中同時運行git命令,而不是分別運行。

克隆后,我創建了一個補丁,將其推送到遠程存儲庫中。 目前,我所有的更改都已提交(即git diff輸出任何內容),狀態是我是master分支之前的提交。

現在,當我運行./g pull -r我得到以下輸出:

victor@victor-laptop:~/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顯示如下:

victor@victor-laptop:~/git/libo$ cd sw
victor@victor-laptop:~/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顯示:

victor@victor-laptop:~/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告訴我我的母版與原版/母版不同。 這種情況持續循環。 請幫幫我。 問題可能是什么,我該如何解決?

為什么git會警告我我的分支與主分支不同?

Git警告您,您的分支已脫離主服務器,因為您的分支已脫離主服務器。

如果我正確地理解了這種情況,那么首先您要在master (稱為A )之上創建一個新提交(稱為B )。 吉特正確地說你是origin master承諾。

A---B

同時,其他人在originmaster之上添加了新的commit:

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

在這一點上,你的masteroriginmaster有分歧。 您有一個提交,而origin/master服務器沒有,而origin/master有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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM