Skip to content

Instantly share code, notes, and snippets.

@keegancsmith
Created October 27, 2017 09:22
Show Gist options
  • Save keegancsmith/e565fbde4638e67c4f11704a4c84eee0 to your computer and use it in GitHub Desktop.
Save keegancsmith/e565fbde4638e67c4f11704a4c84eee0 to your computer and use it in GitHub Desktop.

Revisions

  1. keegancsmith created this gist Oct 27, 2017.
    22 changes: 22 additions & 0 deletions github-push-pr
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    #!/bin/bash

    # Pushes to origin and opens a github compare view of it to speed up PR
    # creation.
    #
    # To install add to $PATH with executable permission and run
    #
    # git config --global alias.pr '!github-push-pr'
    #

    remote=origin
    branch=$(git symbolic-ref --short HEAD)

    # https://github.com/foo/bar.git -> foo/bar
    repo=$(git ls-remote --get-url ${remote} \
    | sed 's|^.*github.com[:/]\(.*\)$|\1|' \
    | sed 's|\(.*\)/$|\1|' \
    | sed 's|\(.*\)\(\.git\)|\1|')

    set -x
    git push ${remote} ${branch}
    open "https://github.com/${repo}/compare/${branch}?expand=1"