Pull Requests as Branches
~169 words. ~0 minutes.
Consider these questions:
- Do you find it annoying to use the web interface to merge pull requests? Do you copy paste the merge instructions from your forge's web interface?
Perhaps you like to checkout the PR branch first? Do you manually add their repository to your config? Perhaps, you use the following command
git fetch -u <pull requester’s git repo url> <their branch name>:<branch name for your repo> git switch <branch-name-for-your-repo>
I used to do these things too.
Then I discovered that, at least on Forgejo, you can just have the PRs
show up as branches, just add the following configuration to your
.git/config file.
[remote "origin-pr"] url = <your git repository’s url> fetch = +refs/pull/*/head:refs/remotes/pr-*
Then run,
git fetch origin-pr
Now you can check out any PR with
git checkout pr-<number>