When creating a repo on a git server and wanting to push your existing local repo for the first time, how do I set the remote?

M a seems to not like me inputting the url, or a name like "origin". It gives me Wrong type argument: stringp, nil.

The command line answer of exactly what I'm looking for is:

git remote add origin git@github.com:user/repo.git

How do I do this in magit?

The magit manual seems outdated here because I can't find the M u option.

This might be related: Magit error on magit-remote-add.

  • 4
    It isn't M-a (Meta+a) but M a (uppercase M followed by lowercase a). Do M-x toggle-debug-on-error RET before doing M a again, so that we get more information about why that error occurs. M u is only available if magit-remote-direct-configure is non-nil and a remote already exists (or more precisely if magit-get-current-remote returns a remote).
    – tarsius
    Jul 22, 2021 at 23:18
  • 3
    Note also that if Magit is installed correctly then the manual is included and available at C-h i g (magit) and it will be the manual for the version you are using, whereas an online manual might be for a different version.
    – phils
    Jul 22, 2021 at 23:49
  • @tarsius thank you for the correction. I didn't realize the ambiguity and will change the OP. I was actually typing M a though. That being said, that must be the reason, I don't actualy have a remote set yet. So that would mean I have to use the command line to setup a repo for the first time? Will make that part clearer in OP too. Jul 26, 2021 at 16:12
  • @phils awesome tip! Will use that moving forward! Jul 26, 2021 at 16:16
  • M a should work when there are no existing remotes. You linked to a similar issue which was fixed upstream... are you using a version of Magit that is more recent than that? If not, then update Magit. If so, use M-x toggle-debug-on-error and add the stack trace from the error to your question.
    – phils
    Jul 27, 2021 at 4:57


Your Answer

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

Browse other questions tagged or ask your own question.