I've been trying to pull in some authenticated git repos on heroku, and hit a few problems.

Ideally, I'd love to be able to use the token solution heregit pull https://<token>@github.com/username/bar.git or even a git pull https://username:password@github.com/username/bar.git solution is acceptable if the token solution isn't.

However, it seems heroku version of git (v1.7.0) struggles with https authenticated clones:

However, installing our own git version on the instance is not ideal as it takes a very long time to compile and install.

It seems that heroku does not offer any free support, which is unfortunte as I just need to tell them to upgrade their git version and all is good. However, as this is not possible, does anyone have any suggestions for doing authenticated https git clones on heroku? (I have managed to get authenticated ssh going by uploading a special .ssh directory with the repo, however that is not ideal for our situation as we would prefer to just use https and tokens).

2 Answers
2

If the git version is indeed 1.7.0, then it is way too old, since multiple fixes were done since then the http transport mechanism.
(like 1.11.7: Pushing to smart HTTP server with recent Git fails without having the username in the URL to force authentication, if the server is configured to allow GET anonymously, while requiring authentication for POST.)

Plus 1.7.8 introduces a way to cache the credentials:

The code to handle username/password for HTTP transactions used in "git push" & "git fetch" learned to talk "credential API" to external programs to cache or store them, to allow integration with platform native keychain mechanisms.

Your ssh workaround is one way, recompiling git another, but until heroku upgrade its default git, I don't see another way to safely authenticate with https for Heroku git repos.