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)
- Github
- 忽略空白字符變化
- 調整Tab字符所代表的空格數
- 查看某個用戶的Commit歷史
- 克隆某個倉庫
- 分支
- Gists
- Git.io
- 鍵盤快捷鍵
- 整行高亮
- 用commit信息關閉Issue
- 鏈接其他倉庫的Issue
- 設置CI對每條Pull Request都進行構建
- Markdown文件高亮語法
- 表情符
- 靜態與動態圖片
- 快速引用
- 快速添加許可證
- 任務列表
- 相對鏈接
- GitHub Pages的元數據與插件支持
- 查看YAML格式的元數據
- 渲染表格數據
- 撤銷Pull Request
- Diffs
- Hub
- 貢獻內容的自動檢查
- 貢獻者指南
- GitHub資源
- Git
- 前一個分支
- Stripspace命令
- 檢出Pull Requests
- 提交空改動 :trollface:
- 更直觀的Git Status
- 更直觀的Git Log
- Git查詢
- 合并分支
- 使用網頁查看本地倉庫
- Git配置
- Git資源