9

Magit is a good option for using Github. When I want to push my commits to Github, it always asks my username and password. How can Emacs save my password?

Best regards.

itirazimvar
  • 809
  • 1
  • 9
  • 20
  • You will undoubtedly get other answers, but here's my unofficial comment based upon a home installation where security is not an issue. The function `magit-process-password-prompt` has a line that reads `(process-send-string proc (concat (read-passwd prompt) "\n"))`. You can substitute `(read-passwd prompt)` with your own hardcoded password -- e.g., `(process-send-string proc (concat "12345678" "\n"))`. The procedure is similar for the username by modifying the function `magit-process-username-prompt`. – lawlist Sep 03 '14 at 21:52
  • 4
    You can either [change to an SSH URL](http://stackoverflow.com/a/11028423/113848) or [create a `~/.netrc` file and keep using HTTPS](http://stackoverflow.com/a/14417827/113848). – legoscia Sep 04 '14 at 07:57
  • Definitely go ssh, if you don't have experience, this is walk you through it: https://help.github.com/articles/generating-ssh-keys – Jordon Biondo Sep 04 '14 at 11:57

1 Answers1

16

This hasn't much to do with Magit. If you configure Git correctly, then it also works in Magit. Either use a ssh key or credential.helper. I recommend the former, but then you also have to configure an ssh-agent and how that is done might differ between distributions.

tarsius
  • 7,639
  • 5
  • 32
  • 44
  • Thanks. I configure my ssh key from Github page from [github](https://help.github.com/articles/generating-ssh-keys) and also 1 times i used from terminal.Now it works. – itirazimvar Sep 09 '14 at 16:03
  • 1
    Or maybe I was just trying to ensure that every Magit question had an adequate answer (by answering those that don't) [as a free service to the users] and in the process kept coming back to this question because its answer was not properly marked as such. I couldn't care less if I had or had not a few additional brownie points. – tarsius Jun 14 '17 at 15:14
  • @tarsius This help: To change the default password cache timeout, enter the following: $ git config --global credential.helper 'cache --timeout=3600' # Set the cache to timeout after 1 hour (setting is in seconds) – Alexei Mar 22 '21 at 17:59