GitHub Merge Button From CLI

DZone's Guide to

GitHub Merge Button From CLI

GitHub is the lifeblood for DevOps, but strangely, some features work better from the GUI than they do from the developers' favorite stomping grounds, CLI. Read to create the CLI-equivalent to the GUI "merge" button.

Download the blueprint that can take a company of any maturity level all the way up to enterprise-scale continuous delivery using a combination of Automic Release Automation, Automic’s 20+ years of business automation experience, and the proven tools and practices the company is already leveraging.

It’s no fun to have to clean up git history after a botched command line merge of a GitHub pull request. I love to live life in the shell, and I don’t want to open a new browser tab just to click The Merge Button, so sometimes I’m stubborn and I don’t. And sometimes I waste a lot of time cleaning up the mess that happens when I try to do all of that with an outdated master branch.

With some prodding and direction from my good friend pengwynn, I put together a script based on the new-to-me Merge Button API Route. Check out the installation and usage instructions below to get set up.

Installation

A nice thing you may not have known about the git command line is that it will automatically alias tools in your path titled git-foo such that they’ll just work when you invoke them as proper git subcommands as in: git foo. So simply download/copy the shell script from my dotfiles, name it git-merge-pr, and copy it into your $PATH and walah, you can invoke it as: git merge-pr.

Usage

Call it with -h for proper usage. The script takes a single, optional argument; either the name of the branch you want to merge in, or the pull request number. If you don’t pass in an argument, it assumes you’ve checked out the branch you want to merge to master. For example, if I’m in the master branch of a repo and someone has opened a pull request for a branch called feature-x, I could merge it from the command-line like so: git merge-pr feature-x.

Now, go forth and merge with glee, in safety, and without leaving our beloved shell. ❤

Download the ‘Practical Blueprint to Continuous Delivery’ to learn how Automic Release Automation can help you begin or continue your company’s digital transformation.