2013-03-04 132 views
3

我跑到下面的一組我的本地回購(分支develop)內的命令,試圖在我的項目的git子目錄(assets/App)鏈接到遠程回購的App目錄,這樣,當他們更新代碼,我可以得到這些更新,而不必從克隆複製/粘貼:丟失的文件

git remote add durandal git://github.com/BlueSpire/Durandal.git 
git fetch durandal #now I have a remote branch with all of Durandal 
git checkout -b durandal durandal/master #now I have a local branch with the contents of durandal/master and have switched to it 
git config core.sparsecheckout true #trying some sparse-checkout stuff, not really understanding what I'm doing 
echo App/ > .git/info/sparse-checkout 
git checkout develop  #back in my develop branch 
git read-tree --prefix=assets/App/ -u durandal  #all hell breaks loose 

在這一點上,我所有的文件從分支develop去除了assets/App/(這是在.gitignore這些文件),它現在有從durandal branch應用程序文件夾複製的內容。我立即跑git reset --hard無濟於事。我試着用沙子重置。不。我嘗試從我的保管箱中取出應該備份了所有東西的遙控器。同樣的交易。我厭倦了轉向主人,所有的文件也從那裏消失了,我完全不明白。我看不出如何恢復。

我知道我不應該在沒有真正理解我在做什麼的情況下做到這一點,但是有人能幫我將我的回購回到我實驗之前的位置嗎?其次,我做了什麼來造成這種情況,我該如何完成我想要做的事情?

回答

1

從基礎去(我從來沒有看着稀疏結賬超越隱約知道它的存在),我想嘗試

rm .git/index 
rm .git/info/sparse-checkout 
git config core.sparsecheckout false 
git checkout [email protected]{yesterday}  # `man gitrevisions` docs the @{} syntax 

,但希望有人誰的實際上是你在哪裏,可以肯定地說這是否會工作。

+0

它的工作!謝謝!我實際上不需要運行最後一個命令,因爲我注意到我的舞臺現在顯示了所有標記爲準備刪除的缺失文件。我'git reset --hard'並恢復正常。 我瞭解到,通過[子樹合併](https://help.github.com/articles/working-with-subtree-merge),可以簡單而安全地完成我之後完成工作的最佳方式。 – neverfox 2013-03-04 20:37:25