【问题标题】:Pushing in submodule in git version 2在 git 版本 2 中推入子模块
【发布时间】:2016-12-13 14:38:24
【问题描述】:

我使用的是 git 版本 2.7.4,带有子模块。我的项目结构是这样的:

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.

如何将其推送到子模块源存储库中?

【问题讨论】:

    标签: git git-submodules git-push


    【解决方案1】:

    我的代码不在master分支,切换到master分支解决了这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-02-22
      • 1970-01-01
      • 2014-07-31
      • 2018-08-02
      • 2021-01-31
      • 2021-03-08
      • 2017-10-05
      • 1970-01-01
      相关资源
      最近更新 更多