0

I have multiple private repositories that I combine into 1 group repo where I pull the changes using submodules.

A person who has access to the group repo, but NOT to my private repos, cannot git submodule update --init --recursive as they will get "access denied" error.

Is there a way to pull and push the whole content of the repositories, not just a path via submodule? To push the actuall files from the repo.

sandalone
  • 41,141
  • 63
  • 222
  • 338

2 Answers2

1

No. Git will always try to fetch the commit from the repository indicated in the file of the latest commit of the superproject.

Let's say in commit abc123 of your superproject (the group repo) the .gitmodules file looks like this:

[submodule "something"]
    path = something
    url = <URL of private repo>  # here you have issues

Either give the person access, or create a special commit where the submodule file points to a different location, maybe on a dev branch.

Or, finally, try to clone the repository, have the person modify by hand the submodule links and then update the submodules with a different .gitmodules file.

Daemon Painter
  • 3,208
  • 3
  • 29
  • 44
1

If you are unable (or don't want to) give this person read access to the private repo, the best you can do is create another clone for them to access. While that seems roundabout, I suppose it could make sense if you didn't want to give them access to the full history. (You could use a shallow clone.) You would eitehr host the clone separately, or send it to them directly (perhaps as a bundle that they can use to populate a local repo).

Once they have a URL from which they can access the required commit(s), the should update their local repo's config. They should avoid changing the .gitmodules file, in the same way that local exclusions should not be put in .gitignore. You can find more information about local config for submodules here:

https://stackoverflow.com/questions/42028437/how-to-change-git-submodules-url-locally/42035018#:~:text=If%20you%20want%20to%20modify,that%20you%20want%20to%20push.&text=Then%20modify%20the%20.,the%20submodule%20URL%20as%20usual.

Mark Adelsberger
  • 42,148
  • 4
  • 35
  • 52