-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a convenient way to add gh cli as a git credential helper #3796
Comments
Thanks for the suggestion! This is a good idea, as I often find myself suggesting these manual instructions to our users 👍 |
i.e. expose this as a new command? https://github.com/cli/cli/blob/trunk/pkg/cmd/auth/shared/git_credential.go#L58 If that's all there is, I'd be happy to take this. |
@despreston yup, that is the idea. |
Thank you all! It took me a good half an hour of googling to stumble upon this command. |
@mikeboiko - Could you do me a favor and comment with all of the google search terms you used to try to find this info? If you post them here then they will be indexed for the next dev to find it faster. Thanks! |
Great idea! I searched the following in google:
|
Thanks. I also added to my blog post that led to filing this issue https://blog.jongallant.com/2021/06/codespaces-gh-cli-git-credentials/ Hopefully this helps get people here! |
What is the purpose of the |
I would leave the $ gh auth setup-git
#=> writes configuration to `~/.gitconfig` For simplicity, I imagine that the command should be non-interactive. There is now a question for which GitHub hosts should the command set up a credential helper? I would propose that all hosts that gh is currently authenticated with should be covered. Additionally, there could be a |
Adds a new command `gh auth setup-git [<hostname>]` that sets up git to use the GH CLI as a credential helper. The gist is that it runs these two git commands for each hostname the user is authenticated with. ``` git config --global 'credential.https://github.com.helper' '' git config --global --add 'credential.https://github.com.helper' '!gh auth git-credential' ``` If a hostname flag is given, it'll setup GH CLI as a credential helper for only that hostname. If the user is not authenticated with any git hostnames, or the user is not authenticated with the hostname given as a flag, it'll print an error and return a SilentError. Closes cli#3796
Adds a new command `gh auth setup-git [<hostname>]` that sets up git to use the GH CLI as a credential helper. The gist is that it runs these two git commands for each hostname the user is authenticated with. ``` git config --global 'credential.https://github.com.helper' '' git config --global --add 'credential.https://github.com.helper' '!gh auth git-credential' ``` If a hostname flag is given, it'll setup GH CLI as a credential helper for only that hostname. If the user is not authenticated with any git hostnames, or the user is not authenticated with the hostname given as a flag, it'll print an error and return a SilentError. Closes cli#3796
Adds a new command `gh auth setup-git [<hostname>]` that sets up git to use the GH CLI as a credential helper. The gist is that it runs these two git commands for each hostname the user is authenticated with. ``` git config --global 'credential.https://github.com.helper' '' git config --global --add 'credential.https://github.com.helper' '!gh auth git-credential' ``` If a hostname flag is given, it'll setup GH CLI as a credential helper for only that hostname. If the user is not authenticated with any git hostnames, or the user is not authenticated with the hostname given as a flag, it'll print an error and return a SilentError. Closes cli#3796
Just a heads up that I created a GitHub CLI extension for this - just as an experiment with CLI extensions The extension also clears the GITHUB_TOKEN env var and runs I'll move the extension to the new setupgit cmd once it is ready. Looking forward to it! |
As part of this, it would be great for the docs for this feature to note that gh will act as its own credential helper on systems where there isn't one by default (as @mislav explained in #2449 (comment)). |
[credential "https://github.com/"]
helper =
helper = !/usr/local/bin/gh auth git-credential
[credential "https://gist.github.com/"]
helper =
helper = !/usr/local/bin/gh auth git-credential What's the reason for the empty value in
|
@sjackman The blank line is intentional to break the chain of previously configured global helpers when handling authentication for these hosts. Otherwise, git would have used a whole stack of each configured credential helper, copying the tokens between them, and we didn't want that for |
Just wanted to say that this is an excellent feature, thanks folks. |
This is 2023, and |
@akwotom To see what
You should see that it invokes |
Describe the feature or problem you’d like to solve
Right now, I have to google and trial and error to get the gh cli wired up as a git credential helper.
This command works:
But I would prefer this be baked into the cli.
Proposed solution
Something like:
gh auth setup-git-credential-helper
Which would execute the commands above or the appropriate commands for a given os/arch combination.
Additional context
Add any other context like screenshots or mockups are helpful, if applicable.
azsdke2e
azsdke2e2
The text was updated successfully, but these errors were encountered: