Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

heroku + git submodule needs authentication

We are using gitolite to manage our repositories and one of our heroku project's have git submodules. Is there a way to get Heroku's public key for the authentication?

Thanks, David

like image 399
seriakillaz Avatar asked Feb 22 '12 18:02

seriakillaz


People also ask

How do submodules work in git?

A git submodule is a record within a host git repository that points to a specific commit in another external repository. Submodules are very static and only track specific commits. Submodules do not track git refs or branches and are not automatically updated when the host repository is updated.

How do I add a submodule to a git repository?

In order to add a Git submodule, use the “git submodule add” command and specify the URL of the Git remote repository to be included as a submodule. When adding a Git submodule, your submodule will be staged. As a consequence, you will need to commit your submodule by using the “git commit” command.

Can you push to a submodule?

Pushing updates in the submodule. The submodule is just a separate repository. If you want to make changes to it, you should make the changes in its repository and push them like in a regular Git repository (just execute the git commands in the submodule's directory).

What is git submodule sync?

git submodule sync synchronizes all submodules while git submodule sync -- A synchronizes submodule "A" only. If --recursive is specified, this command will recurse into the registered submodules, and sync any nested submodules within.


3 Answers

No, probably not. Instead, you can use HTTPS basic authentication when you create the submodule in your git repository, similar to deploying private gems to Heroku. Looks something like this:

git submodule add https://username:[email protected]/username/repo.git
like image 108
kanzure Avatar answered Sep 19 '22 13:09

kanzure


You can also commit a .ssh directory containing a dedicated id_rsa key ("deployment key") that is registered with github, either with your account or a dedicated deployment account. Don't forget to chmod 0660 the key.

like image 32
Leonhardt Wille Avatar answered Sep 20 '22 13:09

Leonhardt Wille


There is another solution to @kanzure approach: https://stackoverflow.com/a/29464430/990356

Go to Settings > Personal access tokens and generate a personal access token with repo scope enabled.

Now you can do git clone https://[email protected]/user-or-org/repo and in the case of a submodule git submodule add https://[email protected]/user-or-org/repo

Pros:

  • very simple approach
  • token can be easily revoked
  • your real password is safe

Cons:

  • if someone has access to the token, he can access your GitHub repos (read and write)
like image 20
tanguy_k Avatar answered Sep 22 '22 13:09

tanguy_k