🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
Pull Request是一种GitHub上可以通过以下多种方式在本地被检索的特别分支: 检索某个分支并临时储存在本地的 `FETCH_HEAD` 中以便快速查看更改(diff)以及合并(merge): ~~~ $ git fetch origin refs/pull/[PR-Number]/head ~~~ 通过refspec获取所有的Pull Request为本地分支: ~~~ $ git fetch origin '+refs/pull/*/head:refs/remotes/origin/pr/*' ~~~ 或在仓库的 `.git/config` 中加入下列设置来自动获取远程仓库中的Pull Request ~~~ [remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* url = git@github.com:tiimgreen/github-cheat-sheet.git ~~~ ~~~ [remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* url = git@github.com:tiimgreen/github-cheat-sheet.git fetch = +refs/pull/*/head:refs/remotes/origin/pr/* ~~~ 对基于派生库的Pull Request,可以通过先 `checkout` 代表此Pull Request的远端分支再由此分支建立一个本地分支: ~~~ $ git checkout pr/42 pr-42 ~~~ 操作多个仓库的时候,可以在Git中设置获取Pull Request的全局选项。 ~~~ git config --global --add remote.origin.fetch "+refs/pull/*/head:refs/remotes/origin/pr/*" ~~~ 此时可以在任意仓库中使用以下命令: ~~~ git fetch origin ~~~ ~~~ git checkout pr/42 ~~~ [_进一步了解如何检出pull request到本地._](https://help.github.com/articles/checking-out-pull-requests-locally)