0

I have complex problem/case connected with git submodule. I have my own repo on github and third-party submodule (provided by other company, READ ONLY). I dealt with init submodule, update it, add .gitsubmodule and new folder to master repo, etc. - all is working right. Now I want make some changes in submodule files, add new files to submodule or something like that. I did it and then I executed commit from submodule directory level. I changed folder to master repo and git status shows me uncommited commits at submodule folder. So... git commit -a, git push. (When I'm checking git status in submodule directory I'm getting info that Your branch is ahead of 'origin/master' by X commits.)

When I make recursive clone of my repo from github I'm getting error (I suppose caused by changes in submodule):

fatal: reference is not a tree: c19485a57b5152959b9a916409ad5d901c44741d 
Unable to checkout 'c19485a57b5152959b9a916409ad5d901c44741d' in submodule path 'apt'

So, my questions are:

  1. Can I doing changes in submodule and pushing them (and tracking) to github.
    • If yes, what I must do that I will could pull all my repo with submodules and changes within it to another host (some workflow?).
    • If not, how I can circumvent doing changes in submodule with seeing them from my github repo level and pulling to another host
  2. It is at all possible?
Sicco
  • 6,167
  • 5
  • 45
  • 61

2 Answers2

0

I think you forgot to run git push from inside the submodule. This must be done prior to pushing the commit in the enclosing project, or nobody will be able to check out your updated submodule (as the commit does not exist on the remote).

Lily Ballard
  • 182,031
  • 33
  • 381
  • 347
  • I can not run `git push` from submodule because as I sad it's read only repo - I don't have sufficient privileges to writing into. – Artur Sitarski Aug 24 '12 at 09:49
0

The problem is that you want to change the 3rd party repository which you do not have push access to. The solution is to make your own clone of that repository--when you make edits, you should be committing them in the context of that subrepo and pushing them. The outer repository tracks the state of the submodule, but shouldn't be managing changes to the submodule's files.

So the workflow solution is to have your own clone of the 3rd party repo which you do have push access to. You should add your own version of the repo as a submodule to your project. I think this answer will help clear up some confusion on the right way to use submodules (which are admittedly a bit tricky at times).

Community
  • 1
  • 1
Justin W
  • 2,077
  • 12
  • 17