Subscribe to this blog


GitHub is a very useful platform to host free and open source software. For Git users who use the command line for managing their repositories, it can be much quicker to use the command line to also manage their development issues. This article introduces git-hub, a really useful utility to manage pull requests, issues and clones from and at GitHub.

Installation

Debian/Ubuntu

If you are running Debian (or a derivative like Ubuntu), installation is as easy as sudo apt install git-hub. Unfortunately, git-hub is not yet part of Debian stable (ATM Jessie) or in the current Ubuntu releases. See the installation from source as an alternative.

From Source

Make sure to fetch the dependencies first: Python >= 2.7, Git >= 1.7, Docutils. The last one are required to build the manual page. On Debian/Ubuntu, simply execute: apt install python-all git python-docutils.\

Then you clone the repository:

$ git clone https://github.com/sociomantic-tsunami/git-hub
$ cd git-hub

If you are on Debian/Ubuntu, type:

$ make-deb
# dpkg -i *.deb

Otherwise the usual

$ make
# make install

will do the job.

Set Up A Git Repository

There are two ways to set up a git repository for git-hub. It can directly clone repositories and I won't detail the instructions here. Have a look at the manual page.\ If, however, a repository already exists, which has been the case for me, it is easy to configure it to authenticate with GitHub:

cd <repo>
# that will ask for user name and password and create an authentication
# token:
$ git-hub setup
# add upstream to newly created hub section; replace USER and REPO name
# (REPO has to be without the .git suffix)
echo -e '\tupstream = USER/REPO' >> .git/config

The last one can be done by hand too, make sure that you use a tab character for indentation. For GladTeX the last line in .git/config looks like this:

upstream = humenda/gladtex

Tip: With the above instructions, git-hub is only set up for one repository. If you want to give it access for all repositories you might have on GitHub, add this to ~/.gitconfig.

[hub]
    user = YOURNAME
    oauthtoken = TOKEN

The token can be obtained from the repository configuration, for which you just identified. Just look into .git/config.

Usage

Git-hub uses subcommands, as does Git. Every subcommand and also git-hub accept the -h switch and are therefore self-explanatory. For instance, listing issues could look like this:

$ cd fd-dictionaries
$ git-hub issue list
[4] update Chapter 4 of the HOWTO (installation of FreeDict DTDs) (humenda)
    https://github.com/freedict/fd-dictionaries/issues/4

Closing an issue and typing a explanatory message in the favorite editor is easy too:

$ github issue close -e 42

An editor will open and will display a file similar to a git commit. After the user has typed a message, saved and quit, the issue will be closed with that message.

If you want save yourself typing overhead, I suggest the following aliases in your ~/.zshrc (or ~/.bashrc):

alias gh='git-hub'
alias ghi='git-hub issue'
alias ghp='git-hub pull'

My experience is that ghi list is so quick to use that I hardly use the web site, if I want to manage issues.



Comments