1

I have a tools collection which I sync between my computers via git pull on remote repo with working tree.

Whenever some of the tools have git source I add them by 'git submodule add' .

Sometimes I do small modifications, compile tools, and add want to commit it in git repo - my aim is to use them fast with possibility to recompile. What is a proper workflow for that? If I start with:

modulepath/submodulepath/bin$ git add submodulefile
modulepath/submodulepath/bin$ git commit -m "subfix"
modulepath/submodulepath/bin$ git pull origin master
modulepath/submodulepath/bin$ cd ../../
modulepath/$ git add submodulepath;git commit -m "subfix in sub"

then will the commit subfix be propagated after I pull main repo ? I've read here git submodule update that I need to commit first submodule. But with the fact my commit won't be pushed to submodule origin but I want to sync the change between hosts sharing main module, how to proceed? Is it possible to overlay changes in submodule by main module? Or can I start a submodule branch without upstream url - it will only be fetched/merged with parent main module.

Community
  • 1
  • 1
nusch
  • 86
  • 4

1 Answers1

0

But with the fact my commit won't be pushed to submodule origin but I want to sync the change between hosts sharing main module

That the issue here: you need to push first the submodule if you want the main repo to be able to get it back.

The main repo only record the gitlink (special entry in the index) representing the new SHA1 of the submodule.
But if that SHA1 represents a commit which was not pushed by the submodule, a git submodule update won't be able to succeed.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • So why git is called decentralized if in order to share content p2p I need to set up external url on each hosts where some of those are behind NATs and connection is possible only one way? – nusch Jan 22 '16 at 14:45
  • @nusch Because git *is* decentralized. It gets its content from *decentralized* servers. regarding submodule, a parent repo only records the url and SHA1 of its submodule. If that submodule changes locally, it needs to push that change to the url which the parent repo is relying in order to get back that new SHA1. – VonC Jan 22 '16 at 14:48