提交对git子模块的更改

提交对git子模块的更改,git,git-submodules,git-fork,Git,Git Submodules,Git Fork,我正在使用node.js进行机器学习。对于不同的方法,有几个不同的项目,我想使用它们进行比较,所以我创建了一个父存储库,它包含几个(目前有两个)子模块:“感知器”和“分类器”。这两个子模块是我从其他存储库制作的fork 现在,当我在主要的机器学习项目上工作时,我有时会对子模块中的代码做一些轻微的修改。但当我尝试提交更改(到我的fork)时,它不起作用: erelsgl@erelsgl-H61MLC:~/git/machine-learning$ git commit -a # On branch

我正在使用node.js进行机器学习。对于不同的方法,有几个不同的项目,我想使用它们进行比较,所以我创建了一个父存储库,它包含几个(目前有两个)子模块:“感知器”和“分类器”。这两个子模块是我从其他存储库制作的fork

现在,当我在主要的机器学习项目上工作时,我有时会对子模块中的代码做一些轻微的修改。但当我尝试提交更改(到我的fork)时,它不起作用:

erelsgl@erelsgl-H61MLC:~/git/machine-learning$ git commit -a
# On branch master
# 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:   classifier (modified content, untracked content)
#   modified:   perceptron (untracked content)
#
no changes added to commit (use "git add" and/or "git commit -a")

erelsgl@erelsgl-H61MLC:~/git/machine-learning$ git add .

erelsgl@erelsgl-H61MLC:~/git/machine-learning$ git commit -a
# On branch master
# 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:   classifier (modified content, untracked content)
#   modified:   perceptron (untracked content)
#
no changes added to commit (use "git add" and/or "git commit -a")
erelsgl@erelsgl-H61MLC:~/git/机器学习$git提交-a
#论分行行长
#未为提交而暂存的更改:
#(使用“git add…”更新将提交的内容)
#(使用“git签出--…”放弃工作目录中的更改)
#(提交或放弃子模块中未跟踪或修改的内容)
#
#修改:分类器(修改内容、未跟踪内容)
#修改:感知器(未跟踪内容)
#
未向提交添加任何更改(使用“git add”和/或“git commit-a”)
erelsgl@erelsgl-H61MLC:~/git/机器学习$git添加。
erelsgl@erelsgl-H61MLC:~/git/机器学习$git提交-a
#论分行行长
#未为提交而暂存的更改:
#(使用“git add…”更新将提交的内容)
#(使用“git签出--…”放弃工作目录中的更改)
#(提交或放弃子模块中未跟踪或修改的内容)
#
#修改:分类器(修改内容、未跟踪内容)
#修改:感知器(未跟踪内容)
#
未向提交添加任何更改(使用“git add”和/或“git commit-a”)
如何将更改提交到子模块


我不确定子模块是否可行——也许有更好的方法可以在一个主项目中使用多个子项目,这样我也可以向每个子项目提交更改?

您应该首先将
cd
提交到子模块中,并在那里提交更改(基本上是一个单独的repo)。然后在父repo中,您将看到子模块已更新为新提交,您将在主repo中记录(
add
commit
)这一事实

应该是这样的:

# On branch master
# Changes not staged for commit:
modified:   classifier (new commits)

谢谢,这可以从命令行工作,但是,当我尝试从Eclipse提交(使用EGit插件)时,除了我更改的单个文件之外,我还得到文件夹中的所有文件都是“已删除”,子文件夹中的文件都是“新建”。例如,文件“README.md”标记为“removed”,文件“classifier/README.md”标记为“new”。这可能是一个EGit问题。Byt的方式(这是第一个包含子模块支持)建议子模块单独处理。