One of the things I find very handy about Bitbucket is when you push a new branch up to a repo hosted in Bitbucket, it prints out (to the terminal screen) a URL that you can hit to create a PR from that branch you just pushed. Ex:
$ git push origin someBranch
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 313 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote:
remote: Create pull request for someBranch:
remote: https://bitbucket.mydomain.com/projects/PRO/repos/someRepo/compare/commits?sourceBranch=refs/heads/someBranch
remote:
To ssh://bitbucket.mydomain.com:7999/pro/somerepo.git
f6718d4..410cbcb someBranch -> someBranch
I find this to be a huge timesaver over going to Bitbucket, navigating to the repo, finding the "Create Pull Request" button, etc. As such, I'd like something similar for when I'm working with a repo hosted on Github -- after a push of a new branch, have it print out to the terminal a URL I can hit to get to the create PR screen on Github. Anyone know of anything like this?
I know there's a CLI for Github with a pull-request
command, but that prompts you for your password every time which is very annoying, and TBH I like to look at the diff in the UI before actually creating the PR.
Created my own local hook that works well enough for my needs. Add this as a
pre-push
hook to your local clone of a repo:Example output:
I can then hit that url emitted to land on the create pull request page in Github with the branch I just pushed as the source branch.
This isn't quite equivalent to Bitbucket, as it's run locally (the Bitbucket one is run on the remote) so it's not as intelligent (ex: it still emits the URL even if the push resulted in no changes on the remote, etc). But it suits my need of "when I push to a Github repo, I can click a link from my terminal window to get to the create PR page in Github".
I ended up using this (on gitbash, with no
rev
and using the more recent bitbucket):