What is the best way to use Magit with GitHub personal access tokens?

Right now, pushing to GitHub causes Magit to prompt me for a username and password. I have to provide the access token instead of my regular password to authenticate.

Apparently, cloning with SSH instead of HTTPS is the way to go. However, I've already cloned a large number of repos w/ HTTPS. Can I get them to use the token I've specified in my .gitconfig file?

  • Inside the .git directory is a config file which specifies the upstream. You can edit this to change from https to ssh.
    – icarus
    Oct 30 '16 at 4:28
  • I'll give that a try. Oct 30 '16 at 5:24

Magit doesn't deal with authentication directly and leaves that all to Git. The only thing Magit does is that when Git asks the user to provide a password or passphrase, then it forwards that question to the user and later hands the reply to Git.

Git provides many alternative methods for remembering the secret needed to access a remote repository and they all work with Magit. Some of the available options are described here, here, and here.

If you can access remote repositories on the command line without having to provide a secret, but not inside Magit, then that is a configuration issue. For example on Windows your shell and Emacs may not agree on the location of $HOME. See Pushing with Magit from Windows.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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