I have a repo with submodules. I need to access it via https.
The .gitmodules file has this format:
[submodule "submodules/sm1"]
path = submodules/sm1
url = https://bitbucket.org/WORKSPACE/REPO
So if I git submodule update --init, it asks me for a user name (which disallows this from being a non-interactive session, which is pointless)
If I put the user within the url (as mentioned in https://support.atlassian.com/bitbucket-cloud/docs/using-app-passwords/), then I can use GIT_ASKPASS to do a git clone in a scriptable way.
But I don't want to use to put a specific and concrete user within the url in a submodule.
Is there a way to keep the .gitmodules file clean without any ad-hoc username, so I can share a repo between several developers; and also, clone it with its submodules in a scriptable way? None of the previous messages work, they always end up in git complaining about not having access rights.
Hi Francisco,
Is it a requirement to use HTTPS?
If so, please let me know, I'll need some time to look into it.
In case you are ok with using SSH instead, you can use an SSH URL for the repo in the .gitmodules file
[submodule "submodules/sm1"]
path = submodules/sm1
url = git@bitbucket.org:WORKSPACE/REPO.git
SSH URLs do not include a username and authentication is done with SSH keys. This would require users to set up SSH Bitbucket Cloud (if they haven't already), and then authentication for each user will be done with the SSH keys each user has on their own computer.
After setting up an SSH, each user can create a file named config in their ~/.ssh folder with the following configuration, to ensure that the SSH key they generated is used when they connect to bitbucket.org:
Host bitbucket.org
HostName bitbucket.org
User git
IdentityFile /Users/myUser/.ssh/id_rsa
IdentitiesOnly yes
where /Users/myUser/.ssh/id_rsa is the path to the private SSH key in the user's computer.
If you're using a script, you would need to have an SSH key pair on the machine where the script is running. If the script is used to only clone/pull, you could set up Access keys: https://support.atlassian.com/bitbucket-cloud/docs/add-access-keys/
Otherwise, you would need the SSH keys of a user with access to the repo.
If you have any questions, please feel free to let me know.
Just a heads up, I moved your post to a new question. It's best to create a separate question if you need assistance with something, as a new question will have visibility to the rest of my team if I'm out of office, and also because a certain question can become difficult to follow if we try to troubleshoot multiple users' issues.
Kind regards,
Theodora
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.