DZone
DevOps Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > DevOps Zone > GitHub Merge Button From CLI

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.

Ivana Ivanovic user avatar by
Ivana Ivanovic
·
Apr. 29, 16 · DevOps Zone · Tutorial
Like (1)
Save
Tweet
4.03K Views

Join the DZone community and get the full member experience.

Join For Free

github-merge-cliIt’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. ❤

Git Command-line interface GitHub

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • 5 Steps to Strengthen API Security
  • Ultra-Fast Microservices: When Microstream Meets Wildfly
  • Applying Kappa Architecture to Make Data Available Where It Matters
  • Maven Tutorial: Nice and Easy [Video]

Comments

DevOps Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo