Jorge Dias

So many layers of web

I’m a big fan of magit and I’ve been using it for many years and I found some time ago the magithub extension, which is great and allows you to integrate with github, see your pull requests, open the browser for the current project, create PRs, etc.

The main difficulties I had were getting it to work with GHE, I had to do some hacks to get it working like a year ago but it was good and I moved on.

Now I recently had to setup a new computer and the newest version of magithub has changed and my previous configuration didn’t work.

After reading the documentation for magithub, ghub and ghub+ I was still having some problems so after some debugging and reading the source code I found how to make it work which I’ll document here for future reference.

From the magithub FAQ the first thing you need is to setup the correct value of magithub-github-hosts. I tried to customize it but there seems to be a problem and emacs (25.2.1) doesn’t let me use a list so in my .emacs config I added.

(setq magithub-github-hosts '("" "")))

Following the ghub manual the first thing you need to do is setup your username:

git config --global github.user USERNAME

# For GHE
git config --global EMPLOYEE

Then for each corporate repository you should do:

cd /path/to/repo
git config

Now in my case I added a conditional include in my ~/.gitconfig to set this globally for all the work repos (which I have under the same root folder).

So my ~/.gitconfig would include:

	user = diasjorge

[includeIf "gitdir:~/development/work/"]
        path = ~/

And in ~/ I’ll have:

        email = [email protected]
[github ""] # Magithub uses this to make the API requests
	user = jorge-dias
[github] # Make ghub always use this user and host
	user = jorge-dias
	host =

Now with this setup I have seamless integration and I don’t have to remember to configure the for all my repos.

Then you need to configure your ~/.authinfo file. Following the manual I added:

machine login user^ghub password TOKEN
machine login user^magithub password TOKEN

machine login ghe-user^ghub password GHE_TOKEN
machine login ghe-user^magithub password GHE_TOKEN

Notice I add different entries for ghub and magithub packages. This is so you can give different packages that use ghub different permissions.

For magithub the variable magithub-github-token-scopes mentions the required scopes '(repo user notifications).

It took me a while to figure it all out so I hope you find this summary useful and you can enjoy working with magit and Github enterprise using magithub.


comments powered by Disqus