2016-01-08 41 views
1

我有一個團隊git回購有一個子模塊。我不得不進入子模塊並進行更改。我把我的回購推送到遠程服務器。我對子模塊所做的更改未顯示在服務器上。只有非子模塊發生變化。推子模塊git更改到服務器

我的同事也對子模塊進行了更改。推動了變化,並沒有出現。是否有一種將更改推送到子模塊的特定方法?該子模塊是它自己的回購站點,位於服務器上。

回答

1

當您在子模塊文件夾中進行更改時,您需要提交併直接在該文件夾中進行推送。當子模塊提交將被推送時,您將需要轉到父文件夾,然後進行額外的提交,並對已更改的子模塊進行引用,然後推送該提交。

下面是一個例子:

# current folder is parent project 

cd submodule-git 
# making changes in submodule 
touch new-file 
git add new-file 
git commit -m "new file was added" 
git push origin master 

cd .. 
# changing reference to new commit in the parent project 
git add submodule-git 
git commit -m "updated submodule" 
git push origin master 

有時你不能使用一個子模塊的默認遠程URL來推動改變。例如,如果您使用只讀URL,則可以在子模塊中添加一個附加的遠程設備,並使用它來代替原點。這裏是一個例子:

# current folder is parent project 

cd submodule-git 
# adding new remote with name 'write-origin' and ssh://[email protected]/project.git 
git remote add write-origin ssh://[email protected]/project.git 
# making changes in submodule and creating new commit 
git push write-origin master