Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Open a GitHub Pull Request with Hub

DZone's Guide to

Open a GitHub Pull Request with Hub

· DevOps Zone
Free Resource

The Nexus Suite is uniquely architected for a DevOps native world and creates value early in the development pipeline, provides precise contextual controls at every phase, and accelerates DevOps innovation with automation you can trust. Read how in this ebook.

Both in my professional life and in my personal life as an open source project lead, I spend a lot of time working with git in general, and GitHub in particular. GitHub publishes a command line tool called hub, which is a more convenient way than the website for doing a few specific tasks and in particular I've been using it more and more for opening pull requests.

The basic workflow is to create a branch, add your changes, and then push it to GitHub (I'm pushing to my origin, I'm not sure what happens if you're pushing to somewhere else but if you know then please add a comment). Then you have a few options:

  • Create a pull request against origin/master (this is the default):
    hub pull-request
  • Create a pull request against another repo, you'd probably use this for open source or any other situation where you are pushing to a fork but requesting a pull against an upstream repo; use the -b switch and the format owner:branch:
    hub pull request -b joindin:master
  • Create a pull request against a branch called something other than "master":
    hub pull request -b develop
  • Create a pull request against something else entirely! The argument is in the format owner/repo:branch for that

It's fairly common also to alias your "hub" command to "git", which gives you all your existing git functionality with a few special GitHub-aware features like the pull request command you've seen above. I personally don't have it set up this way, but if you do then you can simply s/hub/git/ in the above examples.

If the changes you want to pull request aren't in "the branch named what I'm currently on, in the origin repo" then you can use the same format of arguments with the -h switch also. Whether you prefer to work from commandline, or you're looking to wrap up some of your process in a scriptable way, hub could be pretty handy.



The DevOps Zone is brought to you in partnership with Sonatype Nexus.  See how the Nexus platform infuses precise open source component intelligence into the DevOps pipeline early, everywhere, and at scale. Read how in this ebook

Topics:

Published at DZone with permission of Lorna Mitchell, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}