Skip to content

Instantly share code, notes, and snippets.

@ryan-willis
Last active April 7, 2023 15:12
Show Gist options
  • Select an option

  • Save ryan-willis/5f3e18aa667d4e3f80c6988823258c5b to your computer and use it in GitHub Desktop.

Select an option

Save ryan-willis/5f3e18aa667d4e3f80c6988823258c5b to your computer and use it in GitHub Desktop.
pure git alias to checkout a PR when you don't have access to the branch's origin
[alias]
copr = !sh -c 'git fetch origin pull/$1/head:pr-$1 && git checkout pr-$1' -

"checkout pull request" alias (git copr)

"checkout pull request"

Helpful when you have a GitHub repository that is collaborative where the development workflow stipulates that branch sources for merge/pull requests must come from a fork, and you don't have access to that forked repository and/or its branches.

Will check out a copy of the pull request commit into a branch called pr-${PR_NUMBER}.

For pull request #69

git copr 69

Why not just use gh?

Because this the easier way.

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