There is a A project and the A project has a submodule S
A
|-S
|-B
|-C
A repo: git@github.com:benjamin/A.git
S repo: git@github.com:owner/S.git
To contribute some bug fix, I forked the A repository and cloned it.
$ git clone git@github.com:benjamin/A.git
and then to download a submodule S I commanded
$ git submodule init
$ git submodule update
Okay, the code tree are made well, and I fixed the bug at a file in A and a file in S.
To commit and push the two files,
$ cd S
$ git add modified_file
$ git commit -a -m 'submodule commit'
$ git push
But the push is not work.
ERROR: Permission to owner/S.git denied to benjamin.
fatal: The remote end hung up unexpectedly
Should I also fork S repository either? How do you do in this case?
Yes, a submodule is a git repo in itself.
You need to
AandSlocally (just for your code to compile, ie don’t bother with the submodule status ofSlocally)A, one forS)Only the maintainer of
AandSwill be able to:Sand commitAA, recording the new SHA1 ofS(submodule) and the changes inA.Mark Longair mentions that you can:
Agit submodule initgit submodule update(that will cloneSto the right SHA1, but with ‘S‘ as a remote, not ‘forked-S‘)cd Sgit remote set-url origin <SSH-url-of-fork-of-S>git checkout -b my-changes-to-S: make a branch in order to record your local modification, and to avoid being in a detachedHEADmode.