在處理子模塊時,我有一個git pull的主要問題。我以爲我開始瞭解他們的原則,但顯然不是...在子模塊中的Git拉將創建另一個子模塊
我創建了一個簡單的git repo Super
,並在其中創建了一個子模塊module
。我的第一個問題是,當在module
(我添加一個文本文件)中進行提交併推送代碼時,我可以看到在github上該文本文件沒有進入子模塊module
,但實際上進入了超級項目Super
(子模塊甚至不顯示在github中)。因此,當我在Super
中執行git pull操作時,最終會在我的repo的本地副本中出現文本文件,這些文件已被我的子模塊推入...我不確定我做錯了什麼。這裏的代碼基本上是:
cd module (a text file "Test" was added to be commited)
~/Super/module [master]: git add -A
~/Super/module [master]: git commit -m 'comment'
~/Super/module [master]: git push
cd Super
~/Super [master] : git pull
and now the text file "Test" shows up in my Super next to the submodule "module".
所以這已經是問題,但我可以忍受。我現在進入我的Super
並刪除此文本文件並添加對子模塊module
所做的更改以重新命名最新的子模塊提交。
(after deleting the text file)
~/Super [master] : git add -A
~/Super [master] : git commit -m 'comment 2'
~/Super [master] : git submodule update
~/Super [master] : git pull
~/Super [master] : git push
我現在走在我的子模塊,做一個git拉
~/Super/module [master]: git pull
,這創造一個在超級所有內容的副本,並把它的子模塊module
。所以如果我在module
中做ls
,我發現一個嵌套的子模塊module
,這是個大問題。
~/Super/module/module [master]:
所以我基本上有2個問題:
當我把我的子模塊來更新我的子項目會後,我的子模塊拉當副本去上層項目
,它會創建一個嵌套子模塊。
有人能告訴我我做錯了什麼嗎?我很抱歉,如果這看起來很明顯,但我一直在這個問題上停留,這是非常令人沮喪的。
我從超級添加的.gitmodules文件和的.git /配置:
.gitmodules:
[submodule "module"]
path = module
url = [email protected]:titocazou/Super.git
的.git /配置:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = [email protected]:titocazou/Super.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[submodule "module"]
url = [email protected]:titocazou/Super.git
如果你可以添加Super repo中'.gitmodules'文件的內容和''的內容,這將有所幫助。在超級和模塊回購中的git/config。 – Amber 2013-05-11 01:55:43