2010-12-18 122 views
3

發生了一些奇怪的事情 - 我的開發分支已經失去了所有的歷史,直到最後一次提交。任何人都可以提出原因嗎? 我做過的最後一件事 - 安裝了那個分叉brotherbard GitX並開始使用它(主要用於歷史查看,但也嘗試合併)。歷史圖片現在看起來像http://yfrog.com/h2bf8p,但在開發之前從主人開始並行進行,「特徵形狀填充」分支合併爲兩次開發。我也在開發中積累了一些經驗。 現在開發分支的git日誌只顯示最後一次提交。不說任何像'獨立'的東西。我已經害怕GitX(官方和這個分支),因爲上個星期發生了奇怪的事情 - 二進制.fla文件在過去的幾個提交中沒有被保存過。所有的文本文件都很好,但是這個二進制文件就像4次落後。其他工作目錄在分支之間切換時根本沒有更新(我在控制檯工作,git沒有提到任何錯誤,對他來說很好)。不知道,如果它與gitx有關係嗎?Git:分支已經失去了它的歷史?

UPD: 看起來這裏提到http://groups.google.com/group/gitx/browse_thread/thread/71a0f759d115fee5 這裏同樣的問題是我得到的:

$ git reflog 
157cfca [email protected]{0}: checkout: moving from feature-shape-fill to develop 
46a6163 [email protected]{1}: checkout: moving from develop to feature-shape-fill 
157cfca [email protected]{2}: commit: Rotated drag tip 
7f6c394 [email protected]{3}: commit: TextShapesCanvas is working, 
4765eed [email protected]{4}: merge feature-shape-fill: Merge made by recursive. 
ed44a2c [email protected]{5}: checkout: moving from feature-shape-fill to develop 
46a6163 [email protected]{6}: commit: More tight packaging (thnx to TextLineMetrics), 
59b6d2d [email protected]{7}: checkout: moving from develop to feature-shape-fill 
ed44a2c [email protected]{8}: merge feature-shape-fill: Merge made by recursive. 
67d08b3 [email protected]{9}: commit: Basic grid functionality, need to add text shapes and fix resize-generation 
505479c [email protected]{10}: checkout: moving from feature-shape-fill to develop 
59b6d2d [email protected]{11}: commit (amend): Simple retrovirus non-optomized algorithm 
5ec1b70 [email protected]{12}: commit: Simple retrovirus non-optomized algorithm 
b9eaf18 [email protected]{13}: commit: The most ugly suitable version of fill algorithm 
757f1b7 [email protected]{14}: checkout: moving from feature-shape-fill-predefined to feature-shape-fill 
757f1b7 [email protected]{15}: checkout: moving from feature-shape-fill to feature-shape-fill-predefined 
757f1b7 [email protected]{16}: checkout: moving from feature-shape-fill-auto to feature-shape-fill 
b8e284f [email protected]{17}: commit: Auto fill first steps 
757f1b7 [email protected]{18}: checkout: moving from feature-shape-fill to feature-shape-fill-auto 
757f1b7 [email protected]{19}: commit: Test document created, components::TextShape base draft 
505479c [email protected]{20}: checkout: moving from develop to feature-shape-fill 
505479c [email protected]{21}: checkout: moving from master to develop 

看起來他們不會丟失,但如何讓我的歷史了?

回答

2

你給的圖片顯示你的develop分支是分離的,如果我沒有弄錯的話。

因爲我的理解是基於master分支,你可以把它放回主分支:

git rebase master develop 

重要:首先請你原來.git目錄的備份,在嘗試上述前,因爲我不確定這會產生你想要的結果。

您還可以通過從master創建一個臨時黨支部develop2和合並develop到它那裏得到了類似的結果:

git checkout -b develop2 master 
git merge develop 

希望這有助於!我沒有嘗試過,所以請在嘗試上述步驟之前先備份您的.git目錄!

+0

正如我在upd中發現的,我發現,我可以訪問那些丟失的提交,但是如何讓我的分支(作爲提交歷史記錄)回來?你的方式將簡單地創建一個由單一提交組成的開發分支(從主開始),對吧? – 2010-12-18 14:46:49

+0

@Pavel:我猜想所有的提交都放在master的頂部。如果你只是備份你的.git目錄,你可以很快地嘗試上面的命令,看看他們是否能解決你的問題。 – EOL 2010-12-18 18:29:34

0

要看到的只是開發分支是如何改變使用歷史:

git reflog show develop 

接着是被檢出或添加分支/標籤年長承諾在他們的SHA(或位置,比如開發@ {1}),直到你發現最後一個工作。例如:

git branch test 7f6c394 

查看日誌這些提交似乎是開發以及部分:ed44a2c,67d08b3,505479c

移動開發分支到最後好提交。您可能能夠挑選其他提交,但這取決於導致錯誤的原因。

0

我有完全相同的問題,某個提交的父SHA沒有設置,提交看起來像它存在於項目歷史之外。EOL提供的第一個選項會將您的提交恢復到歷史記錄中,但會丟失所有分支歷史記錄。 (至少,它對我有用。)我最終做的是通過我的reflog查看最後一次提交,之後發送了我的寶貴分支到最後。只見看上去像這樣的臺詞:

6d79889 [email protected]{24}: checkout: moving from online-payment-processing to gift-certificates 
3da6ec3 [email protected]{25}: commit: fix computation of when to skip processing for special orders 

基本上,承諾遵循不同分支的結帳。 (在我的例子中,分支online-payment-processing是一個處於陷阱狀態的分支,並且'從'移動''消息向我保證,以前的提交是在我的分支上的。)我知道HEAD的提交是被搞亂的提交(相反一個更久遠的歷史),所以我發出的命令:恢復我的分支歷史

git rebase 3da6ec3 online-payment-processing

和... ...它得到了固定(後一些解決衝突)