Last active
February 1, 2022 13:53
-
-
Save Stadicus/636651e7273598bf62a2911a097efde5 to your computer and use it in GitHub Desktop.
[alias] in .gitconfig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 [email protected]: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 [email protected]:Stadicus/raspibolt.git (fetch) | |
> origin [email protected]: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