5

I just configured my IRC user name for ERC with (setq erc-nick "name").

Is there a similar variable for Magit, so it knows my Github username. If not, is there some ELisp I could write to add a hook to Magit or something like that?

mwfogleman
  • 131
  • 5
  • 2
    The place for this is in `~/.gitconfig`, I think. – abo-abo Mar 22 '14 at 17:16
  • OK, makes sense. But what variable do I set? Github's intro tutorial just suggests setting your name and your email. – mwfogleman Mar 22 '14 at 17:20
  • That's what I've set: name and email. Github recognizes me by my ssh key and puts my github name in the commit log. – abo-abo Mar 22 '14 at 17:28
  • Hm. I haven't been clear. I can push to Github, but if I've over-stepped the amount of time, I have to re-enter my username and password when I do so. I don't want to set my password (obviously), but I do want it to know my username (which /= my name or my email). – mwfogleman Mar 22 '14 at 17:35
  • 5
    https://help.github.com/articles/generating-ssh-keys – abo-abo Mar 22 '14 at 17:38
  • The answer to this specific question is [here](http://stackoverflow.com/a/25454899/834521), i.e. add the lines `[credential "https://github.com"]` and `username = my-github-username` to your `.gitconfig`. When I do this, Magit no longer asks for my github username. If you don't want to type your password either, you can go down the `ssh` keys route. – TooTone Mar 02 '15 at 14:17

2 Answers2

5

Here is how to set your configuration using the command-line:

/usr/local/git/bin/git config --global github.token 123456789

/usr/local/git/bin/git config --global github.user tiago

/usr/local/git/bin/git config --global user.name tiago

/usr/local/git/bin/git config --global user.email tiago@stackoverflow.com

;; for OSX
/usr/local/git/bin/git config --global credential.helper osxkeychain

/usr/local/git/bin/git config --global core.excludesfile ~/.gitignore_global
lawlist
  • 13,099
  • 3
  • 49
  • 158
-1

Looking for username in magit.el, I found the following function:

(defun magit-process-username-prompt (proc string)
  "Forward username prompts to the user."
  (let ((prompt (magit-process-match-prompt
             magit-process-username-prompt-regexps string)))
    (when prompt
      (process-send-string proc
                       (concat (read-string prompt nil nil
                                            (user-login-name))
                               "\n")))))

If you set up the variable user-login-name to your github nickname, you will at least have it as a default choice (just press enter).

You can also redefine the magit-process-username-prompt, replacing the (read-string...) - with your username. Beware that in this case, if you ever have to login with another username, you'll have to re-activate the original version.

The best advice was indeed given by @abo-abo : ssh keys make everything easier.

Tiago
  • 212
  • 4
  • 16