2016-11-30 43 views
0

我在VS2015中做了一個提交,但是我還沒有推送它。然後我用Git Extension做了一個提取,我可以看到,我在遠程分支後面提交了2個提交。但是Git Extension並沒有向我展示我的本地提交。當我在Git Extension中提交哈希後搜索時,他也沒有找到它。爲什麼?爲什麼不能另一個程序看到我的本地(unpushed)提交?

git status也只顯示我,我是兩個提交後面的遠程分支。 git log @{u}..在控制檯上沒有顯示任何內容。 git log origin/master..HEAD只顯示舊提取的遠程提交。

我想做一個rebase,但現在我不知道這是否是一個好主意,如果Git Extension無法看到我的本地提交。

+0

在這種情況下,誰是「他」? –

+0

「he」= Git擴展 – testing

+0

對於這個問題,我很抱歉,但你確定你在同一個文件夾上工作嗎?你使用一個分支? – Ivan

回答

1

嘗試使用git reflog查看本地存儲庫中的歷史更改。

如果您在那裏找不到您的提交 - 請檢查您在不同地方沒有兩個存儲庫副本。

+0

不,它是相同的副本。但你非常有幫助!如果您對解決方案感興趣,請參閱我的答案。 – testing

0

git reflog顯示我:

1d63279 [email protected]{0}: checkout: moving from 9af729af1fbb639a5616528a31e7773f99f564d3 to refactor 
9af729a [email protected]{1}: commit: My missing commit 
1d63279 [email protected]{2}: checkout: moving from 0e302fee7cbb0ba1306a75e024e324291e3e361f to 1d6327972bd9ac1a585d947e634b69f891a78325 
0e302fe [email protected]{3}: checkout: moving from refactor to 0e302fee7cbb0ba1306a75e024e324291e3e361f 
1d63279 [email protected]{4}: commit: My old commit 

如此看來,我已經簽出在此期間的特別承諾和對工作。我的解決方案是製作一個patch

// create patch 
git format-patch -1 9af729af1fbb639a5616528a31e7773f99f564d3 
// show stats 
git apply --stat 0001-My-Commit-Message.patch 
// check for error before applying 
git apply --check 0001-My-Commit-Message.patch 
// three-way merge and apply the patch 
git am -3 < 0001-My-Commit-Message.patch 

現在一切都應該好了,我可以進一步工作。但我不知道舊提交會發生什麼。

相關問題