2016-12-13 119 views
1

我使用從git 2.7.4版本與子模塊。我的項目結構是這樣的:在git版本2推子模塊

main/ 
    file1 
    file2 
    subm1/ 
     file3 
     file4 
    subm2/ 
     file5 

根據this question我想在子模塊推。例如,在file3的改變後,我使用這個命令來推:

cd subm1/ 
git add file3 
git commit -m 'Update file3' 
git push origin master 

我收到此錯誤:

Pushing submodule 'subm1' 
To <submodule git repo> 
! [rejected]  master -> master (non-fast-forward) 
error: failed to push some refs to <submodule git repo> 
hint: Updates were rejected because a pushed branch tip is behind its remote 
hint: counterpart. Check out this branch and integrate the remote changes 
hint: (e.g. 'git pull ...') before pushing again. 
hint: See the 'Note about fast-forwards' in 'git push --help' for details. 
Unable to push submodule 'subm1' 
fatal: Failed to push all needed submodules! 

但是當我使用拉這樣收到Already up-to-date

subm1$ git pull origin master 
From https://gitlab.com/systemnegar-ai/compare 
* branch   master  -> FETCH_HEAD 
Already up-to-date. 

如何將它推入子模塊源存儲庫?

回答

0

我的代碼不在master分支,切換到master分支解決了這個問題。