Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

different push/pull urls for git submodule

I'm using the git superproject pattern in a large project which is deployed by a Teamcity build agent which does not have a repository account, however the repository is set up to allow anonymous cloning. For this reason I have set up the submodules with their http:// url rather than their git url. The issue with this is that the repository rejects http pushes:

Total 0 (delta 0), reused 0 (delta 0)
error: RPC failed; result=22, HTTP code = 401
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly

So every time I update the submodules when switching branches, I have to do a git remote add-url --push to add the git:// url.

Is there any way to set up the submodules in the superproject such that they already use the http:// url for pulling and the git:// url for pushing?

like image 416
theheadofabroom Avatar asked Apr 18 '13 10:04

theheadofabroom


1 Answers

The LibreOffice project also uses submodules and includes:

By default you submodules repository is in a state called 'detached HEAD' that means that the commit checked-out -- which is the one that the super-project (core) need -- is not associated with a local branch name.

Don't forget to add a correct pushurl for the submodule you are working on or you will not be able to commit.

$ editor .git/modules/submodule/config

And in the section [remote "origin"] add:

pushurl = ssh://logerrit/submodule

(similar to soulseekah's comment) (in your case, use a git:// address)

You can also do it through (within a submodule)

git config remote.origin.pushurl git://...

If you don't, as illulstrated in this project, you would get a:

fatal: The remote end hung up unexpectedly
like image 132
VonC Avatar answered Sep 27 '22 21:09

VonC