I'd like to configure magit so that it does not prompt me for my GitHub username when it needs to interact with GitHub in some way (like, say, when doing a push).

My GitHub username is already in the github.user elisp variable and git variable, which should be enough according to the ghub documentation, but for some reason it keeps prompting me for my username every time I push.

magit gets my password from an external program which prompts me for my gpg key password which is used to decrypt my GitHub password in pass, and that part works fine.

I also have forge set up to use pass, and when using forge functions from magit I'm not prompted for my username, and only prompted for my gpg key password which decrypts my GitHub password in the same way it does for magit. So if forge could be set up not to prompt for my username, I'd expect there should be some way to configure magit act the same.

Here is my setup:

In my emacs config:

(require 'auth-source-pass)
(setq auth-sources '(password-store))
(add-hook 'magit-process-find-password-functions
(setq github.user "myusername")

From a shell, I typed:

git config --global github.user myusername

So now my ~/.gitconfig contains:

    user = myusername

My ~/.password-store directory tree looks like this:

├── api.github.com
│   └── myusername^forge.gpg
└── github.com
    └── myusername.gpg

I also tried sticking ^magit after myusername and putting both of these variations under api.github.com, like the forge entry was, but that didn't help.

1 Answer 1


I use pass and the password package in Emacs but for GitHub/GitLab interaction I use SSH keys. Upload your public key to your account and use something like keychain to store your keys on initial login.

Ocassionally I find Emacs doesn't find the Keychain agent so I've the following key-binding to reload..

(global-set-key (kbd "C-c k") 'keychain-refresh-environment)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.