Search

Search IconIcon to open search

Checking out PR (and branch) from existing PR (git worktree)

Last updatedUpdated: by Simon Späti · CreatedCreated: · 1 min read

First, we need to configure to fetch PRs. We will add to .git/config which is located under root/config for git worktree repos:

After we fetch all PRs and included metadata with a simple git fetch. This will fetch lots of metadata for big repos.

# Checkout PR

After we are able to pull PRs from with the prefix pr/, which is known by git as the repo for PRs. It will automatically checkout the associated branch.

1
2
git worktree add simon/20643_docs_dagster pr/20643
# might be you need to add `origin/pr/20643`

I had trouble checking out the branch associated with the PR. I would find and could checkout with git worktree add simon/<name-i-want> <existing-branch-name>, but opened the git history, the commit from the PR wouldn’t be there. Checking out the PR instead as explained above, it works like a charm.


Origin: Checking out GitHub pull requests to a local branch · Blag