Skip to content
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

FR: Allow using Github Tokens from gitconfig files #203

Open
pataquets opened this issue Jul 1, 2024 · 2 comments
Open

FR: Allow using Github Tokens from gitconfig files #203

pataquets opened this issue Jul 1, 2024 · 2 comments

Comments

@pataquets
Copy link

git config retrieves configuration values from its default config files (see man git-config) using section.key syntax and previously set also with git config.
Examples:
https://github.com/mhayashi1120/yagist.el/blob/master/README.md#config
https://www.spacemacs.org/layers/+source-control/github/README.html#git-configuration

Git takes care of choosing/finding the proper file according to OS/user/system global,etc.
It would be great to allow bin to read the token from a bin.github-token section key.

Also, Git credential helpers might come handy (although I've not used it, so far).

@marcosnils
Copy link
Owner

TIL that adding PAT's in the gitconfig is such a thing. Is there any other source I can ready about this a bit more? I find ir surprising that neither the github docs or the gh CLI mention anything about storing the token this way. In fact, the gh CLI suggests using the GH_TOKEN or GITHUB_TOKEN variables here: https://cli.github.com/manual/gh_help_environment

@pataquets
Copy link
Author

Aside from the mentioned Emacs packages (which use git config --global shell calls), I've looked at my own gitconfig and found sections:
[tig]: https://jonas.github.io/tig/doc/tigrc.5.html
[github]: I guess it belongs to gh Github CLI
[gitlab]: Ditto for glab (I can't remember for sure, not checked myself, just guessing)
[delta]: A syntax-highlighting pager for git, diff, grep, and blame output

Also, libgit's C API features gitconfig functions, so I guess it's a pretty widespread practice. It's also very convenient, since you can centralize all your global Git tooling config in a single file and also repo-local configs. You can also do some fancy conditional including (e.g. depending on your current dir).

HTH.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants