Skip to content

Instantly share code, notes, and snippets.

@ollyg
Last active August 14, 2017 14:28
Show Gist options
  • Save ollyg/9db70a621d0638b491354e39e5b27bf1 to your computer and use it in GitHub Desktop.
Save ollyg/9db70a621d0638b491354e39e5b27bf1 to your computer and use it in GitHub Desktop.
Inspect a github pull request
[alias]
branchlog = "!git log --oneline --decorate --left-right --graph master..."
pr = "!sh -c \"git checkout -b pr/$1 && curl -sL $(git config --get remote.origin.url | sed -e 's|:|/|' -e 's|^git@|https://|' -e 's|\\.git$|/pull/$1.patch|') | git am --whitespace=nowarn\" -"
pr-clean = "!git checkout - ; git for-each-ref refs/heads/pr/* --format=\"%(refname)\" | while read ref ; do branch=${ref#refs/heads/} ; git branch -D $branch ; done"
@ollyg
Copy link
Author

ollyg commented Apr 4, 2017

Use these aliases to help with testing and evaluating Github pull requests.

  • check out pull request 14 into a new branch (from your current location)
    git pr 14
  • jump to the previous branch you were working on, and delete any pull request branches
    git pr-clean
  • show commit log since the branch from master (and any commits to master not in the branch)
    git branchlog

This is a little simplistic - it assumes you have a clean HEAD to which the pull request cleanly applies. It assumes you only work on one pull request at a time, and you do it all in one go so you revert to the previous used branch.

Use at your own risk - no warranty, implied or otherwise.

@ollyg
Copy link
Author

ollyg commented Aug 14, 2017

When working with PR from a fork, additional steps are required to update the PR.

  • First fetch the PR branch:
    git fetch git://github.com/USERNAME/netdisco-mibs.git BRANCHNAME
  • Then force push back to that branch:
    git push git://github.com/USERNAME/netdisco-mibs.git +pr/NN:BRANCHNAME

In the above, NN is the PR number and BRANCHNAME is the PR branch at the repo fork (given under "Command Line Instructions" on the PR page).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment