hickford/git-credential-oauth

Possible to specify credential helper as an env var?

Closed this issue · 4 comments

Is it possible to temporarily specify git-credential-oauth as the credential helper like GIT_SSH_COMMAND, but for HTTPS?

I'd like to be able to do a one-time similar to this:

GIT_HTTPS_COMMAND=git-credential-oauth command

At the moment I'm creating the .gitconfig and then deleting the file. It works, but thought I'd ask if there's a better way :)

You can specify any Git configuration setting temporarily following https://git-scm.com/docs/git#Documentation/git.txt--cltnamegtltvaluegt

git -c credential.helper=oauth push

or ignoring ignoring other credential helpers:

git -c credential.helper= -c credential.helper=oauth push

May I ask why you want to do this? https://xyproblem.info/

More convenient would be to set Git configuration specific to one repository:

git config --local credential.helper=oauth

or specific to one host:

git config --global credential.https://example.com.helper=oauth

Thank you @hickford! Your first command worked :)
The reason I wanted to do this without creating a .gitconfig is that I'm running this on a host that is diskless and I wanted to be able to use OAUTH instead of creating a GitHub personal access token.

Better surely to also configure a storage helper such as cache so you don't have to reauthenticate on each command?

git -c credential.helper="cache --timeout 3600" -c credential.helper=oauth push

Equivalently

[credential]
helper = cache --timeout 3600
helper = oauth

Equivalently

git config --global --add credential.helper "cache --timeout 3600"
git config --global --add credential.helper oauth

Just wanted to thank you again! This has worked very well in the last week :)