Skip to content

Instantly share code, notes, and snippets.

@Stadicus
Last active February 1, 2022 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Stadicus/636651e7273598bf62a2911a097efde5 to your computer and use it in GitHub Desktop.
Save Stadicus/636651e7273598bf62a2911a097efde5 to your computer and use it in GitHub Desktop.
[alias] in .gitconfig
# Put the following "alias" in your `.gitconfig` file:
```
[alias]
pr = "!f() { git fetch -fu ${2:-$(git remote |grep ^upstream || echo origin)} refs/pull/$1/head:pr/$1 && git checkout pr/$1; }; f"
```
# Clone the RaspiBolt fork from your own GitHub user space (with SSH for write access)
$ git clone git@github.com:Stadicus/raspibolt.git
$ cd raspibolt
# Add the original RaspiBolt repository (with HTTPS, read-only)
$ git remote add upstream https://github.com/raspibolt/raspibolt.git
$ git remote -v
> origin git@github.com:Stadicus/raspibolt.git (fetch)
> origin git@github.com:Stadicus/raspibolt.git (push)
> upstream https://github.com/raspibolt/raspibolt.git (fetch)
> upstream https://github.com/raspibolt/raspibolt.git (push)
# Use the "pr" alias to check out the pull-request (e.g. #735) into a new branch in your local repository
$ git pr 735
> Switched to branch 'pr/735'
# Push the local branch to your RaspiBolt fork on GitHub
$ git push --set-upstream origin pr/735
> Branch 'pr/735' set up to track remote branch 'pr/735' from 'origin'.
# Now you can go to your forked repository > Settings > Pages, and publish the branch pr/735 to GitHub pages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment