我們的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
任何人都可以解釋我們做錯了什麼?
有信息丟失(所以不能確切說出發生了什麼),但請注意,當你'git rebase',你*複製*提交(然後放棄原來的贊成新副本)。如果您僅對自己的*,未推送的提交進行重定位,則沒有其他人擁有您的舊版本,但如果您以某種方式重新設置了某個*其他*的(推送/發佈)提交,則也會複製它們*。這幾乎肯定發生了什麼。要將兩個副本都放到歷史記錄中,您可以將副本與他們的副本合併(這將顯示在'--graph'輸出或gitk等中)。 – torek 2014-09-12 11:27:29
看來這可能是有效的。是否還有更多信息可以幫助您從哪裏尋找出發點?我有點迷路。附: '--graph'輸出只顯示一條線性路徑。 – LeonardChallis 2014-09-12 11:31:13
真的需要知道每個用戶做了什麼,或者從服務器上看/看過很多日誌。至於日期排序,請注意每個提交都有* 2個*時間戳:作者日期和提交者日期。日誌排序默認使用提交日期,而「媒體」格式只顯示作者日期。 (當使用'--graph'時,日誌排序被強制爲'--topo-order'。) – torek 2014-09-12 11:40:45