I am working on machine learning with node.js. There are several different projects for different methods, and I want to use all of them for comparison, so I created a parent repository machine-learning, that contains several (currently two) submodules: "perceptron" and "classifier". The two submodules are forks that I made from other repositories.
Now, while I work on the main machine-learning project, I sometimes make slight modifications to code in the submodules. But when I try to commit my changes (to my fork), it doesn't work:
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")
How can I commit my changes to the submodules?
I am not sure submodules are the way to go - maybe there is a better way to use several sub-projects in a single main project, so that I can also submit changes to each subproject?
You should first cd
into a submodule and commit your changes there (it's basically a separate repo). Then in your parent repo you'll see that the submodule was updated to a new commit and you'll record (add
and commit
) this fact in your main repo.
It should look like this:
# On branch master
# Changes not staged for commit:
modified: classifier (new commits)