On December 8, 2021 7:52 AM, Fabian Stelzer wrote: > On 07.12.2021 09:50, rsbecker@xxxxxxxxxxxxx wrote: > >On December 6, 2021 6:54 PM, Robert Coup wrote: > >> On Mon, 6 Dec 2021 at 23:10, <rsbecker@xxxxxxxxxxxxx> wrote: > >> > > >> > git@xxxxxxxxxxxxx:project/module.git > >> > > >> > When in SSH mode, clones are simple with --recurse-submodules doing > >> > what we want. However, we had to clone on a system where SSH was > >> > locked down and we could only use HTTPS. The form of the URIs > >> > changed > >> rather radically: > >> > > >> > https://user@xxxxxxxxxxxxx/project/repo.git > >> > > >> > I'm looking for better practices than I used - I'm sure there is at least > one. > >> > >> AFAIK the existing `url.<base>.insteadOf` config option[1] deals with > this... > >> > >> [1] https://git-scm.com/docs/git-config#Documentation/git-config.txt- > >> urlltbasegtinsteadOf > >> > >> $ git config --global url."https://user@xxxxxxxxxxxxx/".insteadOf > >> "git@xxxxxxxxxxxxx:" > >> > >> If you don't want to set it globally (not a throwaway CI > >> environment?) then you can do it as a one-off: > >> > >> $ git -c > url."https://user@xxxxxxxxxxxxx/".insteadOf="git@xxxxxxxxxxxxx:" > >> clone --recurse-submodules git@xxxxxxxxxxxxx:repo/project.git > >> > >> But it isn't persisted into your repo config then, so subsequent > >> fetches won't work. You'd need to persist it using something like: > >> > >> $ git config url."https://user@xxxxxxxxxxxxx/".insteadOf > >> "git@xxxxxxxxxxxxx:" > >> $ git submodule foreach --recursive 'git config > >> url."https://user@xxxxxxxxxxxxx/".insteadOf "git@xxxxxxxxxxxxx:" ' > >> > >> Maybe there's an opportunity to make that part easier? > > > >Well, I gave this a shot. The mapping did not appear to work - I tried > >a few combinations. I was left with the original URIs. Note that I also > >had to do > > > >$ git submodule init > > > >which reported the wrong URIs > > > >$ git submodule update > > > >which obviously failed since they were still using SSH. > > > >I think there may be something not working correctly with the insteadOf > operator. This is easily reproduceable. > > > > I ran into this as well some time ago. For submodules this only works if you > put it into your global config since the parent projects config is not relevant to > the submodule. > > There's some discussion in the archive about this as well: > https://lore.kernel.org/git/404d109f-e5a7-85a3-e64c- > ab1b21c3045d@xxxxxxxxxxxxx/ The minimal procedure that I got to work is: $ git config --global url."https://user@xxxxxxxxxxxxx/".insteadOf "git@xxxxxxxxxxxxx:" $ git clone --recurse-submodules https://user@xxxxxxxxxxxxx/project/repo.git This leaves .gitmodules untouched and contains the original URIs, so the status is clean and there is no real risk of someone pushing an unwanted URI change back to the upstream repo. I don't see a major downside to leaving the redirect in global as this would be useful for subsequent clones. Any scripting that might depend on .gitmodules being correct would break - not in my case though - to that should probably be noted. I think I have enough to document this consideration in Documentation/gitsubmodules.txt. Thanks everyone. -Randall