修改了git子模块中的内容,但git子模块说是最新的
我无法将我所做的更改推送到git子模块。我已经推动了主要项目,并且得到了这个修改了git子模块中的内容,但git子模块说是最新的,git,git-submodules,Git,Git Submodules,我无法将我所做的更改推送到git子模块。我已经推动了主要项目,并且得到了这个 mainProject$ git status On branch myBranch Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working
mainProject$ git status
On branch myBranch
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
(commit or discard the untracked or modified content in submodules)
modified: example/submod (modified content)
no changes added to commit (use "git add" and/or "git commit -a")
git--version的输出是
git version 1.9.3 (Apple Git-50)
当我跑的时候
mainProject$ git diff example/submod
Submodule example/submod contains modified content
这里发生了什么?我也无法添加主项目中的更改
mainProject$ git add example/submod
mainProject$ git status
On branch myBranch
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
(commit or discard the untracked or modified content in submodules)
modified: example/submod (modified content)
no changes added to commit (use "git add" and/or "git commit -a")
mainProject$git添加示例/submod
mainProject$git状态
在树枝上我的树枝
未为提交而暂存的更改:
(使用“git add…”更新将提交的内容)
(使用“git签出--…”放弃工作目录中的更改)
(提交或放弃子模块中未跟踪或修改的内容)
修改:示例/子模块(修改的内容)
未向提交添加任何更改(使用“git add”和/或“git commit-a”)
您在子模块中签出的提交与在主存储库中提交的不同。
您可以通过以下方式签出子模块的关联提交:
git submodule update
…或者添加此子模块,提交并使用当前更改推送它:
git add example/submod
git commit -m 'new commits in submodule'
git push origin myBranch
您已将内容(提交)记录为项目中子模块的当前状态,并且您的子模块已签出该提交(因为状态未提及提交ID中的任何差异),但是自从签出或提交之后,某些内容被修改了。我也遇到了这个问题,为了解决它,我必须删除子模块并重新添加它。像这样:
git submodule deinit PathTo/SubmoduleName
git rm PathTo/SubmoduleName
sudo rm -rf .git/modules/PathTo/SubmoduleName
git submodule add https://github.com/username/SubmoduleName.git
在此之后,我的项目现在正确显示没有要提交的更改。我想这只是Git子模块实现中的一个bug。在我的情况下,这只是我的愚蠢-我在错误的文件夹中:
- 主项目显示“子模块修改内容”
- 子模块*显示“无更改”
- 我执行git status的子模块文件夹是子模块存储库的实际克隆,我们称之为
,我想我是在~/workspace/mySubModuleRepo
中执行这个注释的~/workspace/mainProject/mySubModule/
git submodule deinit PathTo/SubmoduleName
git rm PathTo/SubmoduleName
sudo rm -rf .git/modules/PathTo/SubmoduleName
git submodule add https://github.com/username/SubmoduleName.git