Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
修改了git子模块中的内容,但git子模块说是最新的_Git_Git Submodules - Fatal编程技术网

修改了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

我无法将我所做的更改推送到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 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 add example/submod,然后运行git status,我会收到相同的消息,即更改不会被提交:(什么显示为“git remote-v”?可能您输入了错误的远程?还要检查“git diff HEAD..origin/master”在您的子模块中。我想问题是您的开发分支与您的源/主模块不对齐。主模块和子模块操作的遥控器都正确,只是编辑了答案。请检查子模块中的“git diff HEAD..origin/master”
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