2014-09-12 307 views
3

我們的git分支存在一個奇怪的問題,我希望更多的是關於我們的理解,而不是像這樣的問題。我將描述我們的工作流程,盡我所能確保我們不會錯過某些明顯的東西:爲什麼git log不按時間順序顯示,代碼已被刪除?

其中一個團隊用git checkout -b newproject做了一個分支,然後做了一些更改,然後用git push -u origin new project推送了這些更改。然後其他開發者加入該項目,使用git fetch origin,然後git checkout newproject

接下來,工作流程如下。開發人員會定期更改,git add新的和修改的文件以及git commit。然後,當他們希望其他人看到他們的更改時,他們將執行git pull origin newproject以獲得自上次拉出以來的任何更改,然後是git push -u origin newproject

注:/etc/gitconfig,我們有以下幾點:

[branch] 
autosetuprebase = always 

我們經常會得到衝突時pull ING,因爲我們在同一個文件的工作很多。當我們這樣做時,我們得到了手動解決衝突的指令,然後運行git rebase --continue我們打開文件,選擇我們想保留的代碼並進行必要的更改並保存。然後,我們git add filename.ext解決時,然後運行git rebase --continue。在完成之後,git status顯示沒有變化,在newproject分支上並且在X提交之前,我們使用git push -u origin newproject

今天早上我們注意到大量的代碼突然失蹤。當運行git log時,我們注意到的第一件事是它不是按照時間順序as the manual suggests

commit bc0903fc5795425908f335cebcab11055869d75d 
Author: billy <[email protected]> 
Date: Thu Sep 11 15:29:37 2014 +0100 

    Add responsive skin to sectionProducts 

commit 7833850313c2974c3b8cbc75383b1834fbf4bf93 
Author: bob <[email protected]> 
Date: Thu Sep 11 14:44:37 2014 +0100 

    Rewrite the way breadcrumbs are generated and output to the page 

commit 09d1318d9e7249e9e45826d7ddc33f23fc5974b1 
Author: bob <[email protected]> 
Date: Thu Sep 11 11:25:21 2014 +0100 

    Fix styles for video and featured product boxes, fix miscellaneous bugs and remove obselete code 

commit 13f01644935092b490be55b6738f500f0f5fcb2e 
Author: bob <[email protected]> 
Date: Thu Sep 11 08:31:03 2014 +0100 

    Fix section.html, add featured products, star buy products and product videos 

commit 01b3bfb3c20f74ea437b221711deabc970f670d8 
Author: bob <[email protected]> 
Date: Fri Sep 12 08:45:19 2014 +0100 

    Refine code for breadcrumbs 

commit 0303bae79f7ff2e84221e0db3f88d3630d4afa91 
Author: bob <[email protected]> 
Date: Thu Sep 11 15:53:06 2014 +0100 

    Modify getBreadcrumbTrail so that it attempts to take the correct route when recursing 

commit 1ae5f00814bf216eda5449a6e8d89123b124fad8 
Author: bob <[email protected]> 
Date: Thu Sep 11 14:44:37 2014 +0100 

    Rewrite the way breadcrumbs are generated and output to the page 

它也出現了一些提交重複。另一點需要注意的是,其中一位開發人員提到,當他們看到一些衝突並解決它們時,然後運行git rebase --continue,他們顯示了另一個衝突列表。在能夠推動之前,它們在所有問題都解決之前發生了幾次。

更新:我們已經注意到,這個問題是最初想到的一個更容易解釋的問題。直到鮑勃推他的承諾,最多承諾與日期Fri Sep 12 08:45:19 2014 +0100,一切都是正確的。它按時間順序排列,代碼正確。接下來的3個提交鮑勃其實是提交前我剛纔提到的3個提交,並加入比利推動他的變化。所以,他們是鮑勃的承諾,但不知何故重新加入比利。另請注意,最終的提交併未重新添加,這是大部分問題似乎源於此的地方。

到Illustrator這一點更好,我提出以下幾點:

87e9a4e Add sectionGroup.html to templates_safelincs 
bc0903f Add responsive skin to sectionProducts 
7833850 Rewrite the way breadcrumbs are generated and output to the page 
09d1318 Fix styles for video and featured product boxes, fix miscellaneous bugs and remove obselete code 
13f0164 Fix section.html, add featured products, star buy products and product videos 
01b3bfb Refine code for breadcrumbs 
0303bae Modify getBreadcrumbTrail so that it attempts to take the correct route when recursing 
1ae5f00 Rewrite the way breadcrumbs are generated and output to the page 
2cc0525 Fix styles for video and featured product boxes, fix miscellaneous bugs and remove obselete code 
cc3c86b Fix section.html, add featured products, star buy products and product videos 

任何人都可以解釋我們做錯了什麼?

+2

有信息丟失(所以不能確切說出發生了什麼),但請注意,當你'git rebase',你*複製*提交(然後放棄原來的贊成新副本)。如果您僅對自己的*,未推送的提交進行重定位,則沒有其他人擁有您的舊版本,但如果您以某種方式重新設置了某個*其他*的(推送/發佈)提交,則也會複製它們*。這幾乎肯定發生了什麼。要將兩個副本都放到歷史記錄中,您可以將副本與他們的副本合併(這將顯示在'--graph'輸出或gitk等中)。 – torek 2014-09-12 11:27:29

+0

看來這可能是有效的。是否還有更多信息可以幫助您從哪裏尋找出發點?我有點迷路。附: '--graph'輸出只顯示一條線性路徑。 – LeonardChallis 2014-09-12 11:31:13

+1

真的需要知道每個用戶做了什麼,或者從服務器上看/看過很多日誌。至於日期排序,請注意每個提交都有* 2個*時間戳:作者日期和提交者日期。日誌排序默認使用提交日期,而「媒體」格式只顯示作者日期。 (當使用'--graph'時,日誌排序被強制爲'--topo-order'。) – torek 2014-09-12 11:40:45

回答

0

爲了完整性,我會在此處發佈原因。

簡而言之,我們正在重寫公共歷史,which is bad。我們現在所做的現在只是從主人到我們的功能分支的重新分配,並且當它與我們自己的頭部應用的提交保持一致時,然後我們合併到主人。實際上,我們也開始壓制提交。儘管我們可能會在幾周前做出最初的提交。

0

我覺得這個序列會產生你所看到的圖表:

  1. 鮑勃推未顯示三個提交,稱他們爲A,B,C,其母公司是cc3^
  2. 比利pull --rebase的他在它們之上工作,但決定不推任何事情
  3. 鮑勃出於某種原因要追溯到和重做那些三個提交,生產cc32cc1ae爲新的A,b,C,並與03001b繼續。
  4. bob力推這個新的歷史,這從比利的分歧cc3^
  5. 比利現在pull --rebase s再次。所以a,b,c和兩個承諾被重新分配到01b,獲得13f,09d,783,作爲他原來的a,b,c和他自己的bc087e的新改版版本。
相關問題