2

I am unable to add a remote repo to github if it does not already exist on github.

E.g.
magit-init Add some files, stage and commit.

Then magit-remote-add --> Remote name:github --> Remote url: https://github.com/username/repoName.git

This fails with:

Updating github
remote: Repository not found.
fatal: repository 'https://github.com/userName/repoName.git/' not found
error: Could not fetch github

It all works fine if go to github.com and create the new repo there first, but this is an extra step. I'm wondering how can I create a new repo on github directly from magit.

2 Answers 2

2

Emacs does not provide any direct functionality to interface with Github directly. Refer to this answer by one our members. He wrote an implementation to create repo from magit.

1
  • Thanks, will give that a try at some point.
    – joelnNC
    Commented Feb 15, 2019 at 18:03
2

You can use Ghub, for example, to create a new repository named "my-cool-project", simply run:

(ghub-post "/user/repos" '((name . "my-cool-project")))

If you want set the name of the repository to the git directory name, you can use:

(when-let ((git-root (locate-dominating-file default-directory ".git"))
           (basename (file-name-nondirectory (directory-file-name git-root))))
  (ghub-post "/user/repos" `((name . ,basename))))

There are also many other optional parameters for creating a new repository, such as description, homepage and private, see https://developer.github.com/v3/repos/#create.

2
  • good suggestion, but does not involve magit.
    – A_P
    Commented Feb 15, 2019 at 19:29
  • 1
    @A_P that's right, since creating a new github project has nothing to do with git/magit.
    – xuchunyang
    Commented Feb 15, 2019 at 21:44

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.