2011-12-03 99 views
0

如果我有一個目錄上的Git回購說/app1是否有可能在目錄/app1/framework上創建一個子回購,基本上我想保留在父目錄內的框架,但我希望能夠克隆framework的內容。從子目錄創建Git回購在父回購

回答

2

我假設你不打算在子回購中也在父回購中添加文件 - 這可能是個壞主意(儘管可能)。

是的,您可以在另一個回購協議下創建回購協議,通常將它們用作 submodules。一般來說,我發現Pro Git book是一個完整但友好的來源。

如果看起來不可思議,下面是一個簡短的總結:Git Submodules Cheatsheet。您將在練習中使用的額外命令:

git submodule add pathto/subrepo  # to add/link a subrepo(app1/framework to parent one /app1, the first time 
git submodule update [--init]   # if parent repo is shared(clone), where someone else added a submodule [--init: first time after the clone] 
git commit        # an extra commit on parent repo to record the changes in the subrepo 
+0

哇,這太複雜了。我嘗試着創建一個新的目錄'/ framework',然後通過符號鏈接到'/ apps1/framework',但那沒什麼用,因爲那個目錄已經在源代碼控制之下了。 – Justin

+0

如果事情可以這麼簡單,那麼很可能_would_就是這麼簡單:)也許你覺得令人困惑的是我第一次鏈接的manpage中的片段 - 但這些更多的只是子模塊特定的命令,它們是從頭開始的完全可運行的演示..剛剛添加了2個可以澄清事情的鏈接..但是,是的,它需要一些努力來理解整個故事,並且額外的複雜性並非沒有目的。 – inger