Using gitb: a command-line tool for Backlog Git

What is gitb?

gitb or “Gitby” is a command-line tool that assists operations related to Git and Backlog.

It is developed by our Nulab Software Engineer, Watanabe. Below is a summary of what he wrote about Gitb for the Backlog blog.

gitb functions

gitb opens up a lot of new functions within the Backlog tool. Here’s a quick summary of some of the main benefits you’ll get by using it:

Open the browser to view information linked to the repository with one command
Open Backlog webpages such as pull requests and issues associated with the current branch, view the list of branches in the current repository, view the list of tags, or view the commit log with just one command.

All git commands can be executed via gitb command
Since the gitb command is a wrapper of the git command, you can run git sub-commands using the gitb command, e.g. gitb pull, gitb push. This allows you to enter commands smoothly without needing to consider whether they are git or gitb commands.

How to install

Homebrew
You can install gitb with Homebrew, a package manager available for MacOS.

brew tap watanabe/gitb
brew install gitb

Go
If you have Go language (go1.13+) installed, you can also install it using go get:

go get github.com/vvatanabe/gitb

Github Release Page

You can download the pre-built binaries for each OS from the GitHub release page. After downloading, add the directory to the path.

Basic usage of gitb

For the full list of gitb commands, specific options, and arguments, please refer to the gitb documentation page.

Open issue list:
gitb issue [-s, –state <STATE>]

Opens the Backlog issue list page for the current project. Filter issues by the value. The value can be specified as ‘all’, ‘open’, ‘in_progress’, ‘resolved’, ‘closed’, or ‘not_closed’ (the default value).

Open an issue:
gitb issue show opens the Backlog issue page associated with the current branch.

Add an issue:
gitb issue add opens the issue creation page where you can add issues to the current project.

Open pull request list:
gitb pr [-s, –state <STATE>]
Opens the Backlog pull request list page of the current repository. Filter pull requests by the value. The value can be ‘open’ (default), ‘closed’, ‘merged’, or ‘all’.

Open pull request:
gitb pr show opens the Backlog pull request page associated with the current branch.

gitb pr show [<PR-ID>] opens the pull request page for the specified PR-ID. When PR-ID is not specified, the pull request page related to the current branch is opened.

Add a pull request:
gitb pr add [-b, –base <BASE>] opens the Backlog page where you can add a pull request with the current branch as a topic branch. BASE is the branch name on which the pull request is based. The default will be empty.

View related pull requests line by line in file:
gitb pr blame [git blame command options] <PATH>

The pull request ID related to the specified change is displayed line by line as shown below. You can also apply the options of the git blame command. This function was created by porting from kazuho/git-blame-pr.pl.

Alias ​​settings

When using the gitb command as a git command, add the following alias to .xxxrc (e.g. .bashrc, .zshrc, config.fish).

Bash, Zsh:
function git() { gitb “$@” }

Fish:
function git gitb $argv end

Now you can use the gitb subcommands like gitb pr and gitb issue as if they were subcommands of git itself without having to worry about entering git or gitb when using the command.

Summary

Thank you for going through this explanation of the gitb command-line tool. It’s a small tool, but it has the potential to make a big difference in your everyday work. Please use its GitHub Issues page if you find any bugs to report, think of questions, or want to start community discussions.

Acknowledgment

  • GitHub’s command-line tool, hub, was a great reference for implementing gitb.
  • The git pr blame command was created by porting from kazuho/git-blame-pr.pl.

Thank you for taking the time to learn about this new tool!