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.

  • On this workflow, does git command needs to be installed on the production server?
  • Folder not showing on github, but is present in git
  • Using TeamCity with BitBucket
  • git archive --format=tar HEAD:mydir/ | tar t -> fatal: current working directory is untracked
  • Git interactive unstage
  • Creating a hidden directory in a repository
  • 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?

  • Git: Ignoring Version-Controlled Files
  • Android Studio not checking Java files into GitHub
  • How can I access one Git repo from two machines?
  • git rm --cached and fatal: pathspec
  • Restore files removed by Git checkout
  • Drop history older than x on cvs2git Migration
  • One Solution collect form web for “different push/pull urls for git submodule”

    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
    Git Baby is a git and github fan, let's start git clone.