I can pull submodule (subby
) latest commit locally with this answer:
$ git clone --recurse-submodules <omitted>/importer.git
$ cd importer
$ cat subby/README.md
cat: subby/README.md: No such file or directory
#
# good ! it's not supposed to exist
#
$ git submodule foreach git pull origin master
Entering 'subby'
<omitted>
Fast-forward
README.md | 1
1 file changed, 1 insertion( )
create mode 100644 README.md
$ cat subby/README.md
Hello oren
#
# good ! now it exists
#
But now I want to push that change
$ git status
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: subby (new commits)
no changes added to commit (use "git add" and/or "git commit -a")
Closing my eyes and hoping for the best worked with:
$ git add subby
$ git commit -m "updating subby"
$ git push
But what exactly did I commit? the sub-folder?
CodePudding user response:
You have committed a gitlink (as shown here), a special entry in the index (documented here) representing the submodule root SHA1.
That way, the git clone --recurse-submodules
knows which commit of that submodule to checkout.