## 參考資料:
* [git pull官方API](https://git-scm.com/docs/git-pull)
## 實踐總結:
* `git pull` 相當于 `git fetch` + `git merge`
* git pull 默認拉取跟當前分支對應的遠程分支代碼;
* git pull origin xxx(xxx 為遠程分支名), 拉取指定分支代碼;
* 測試: 當前分支為 testMerge2, 嘗試 `git pull origin master`;
* 相當于 `git merge master`(如果本地的master跟遠程分支代碼已同步的話)
* 如當前分支是新分支,使用該指令將提示:[本地分支跟遠程分支建立關聯:](http://www.tuicool.com/articles/vQ36Zj)
```
git branch --set-upstream-to=origin/<branch> localBranchName
```
* 最后的 localBranchName 可省略, 省略的話,則將指定的遠程分支與當前分支關聯;
## git pull 常用指令:
* git pull
* 拉取與當前分支關聯的遠程分支代碼(并自動合并當前改動的代碼, 如本地已有commit會產生一個新的commit)
* git pull --rebase
* 拉取與當前分支關聯的遠程分支代碼(并自動合并當前改動的代碼, 如本地已有commit**不會**產生新的commit)
* git pull origin xxx
* 拉取指定遠程分支代碼(并自動合并當前改動的代碼)
* git pull -p
* 更新遠程分支信息,本指令相當于`git fetch --prune origin` 或 `git fetch -p`例如:遠程刪除或新增了新的分支, 本地git branch -va因為緩存看到的并不是最新分支信息,用該指令就能與遠程分支列表保持一致;
* git pull origin master --allow-unrelated-histories
* 把本地一個寫了很久的倉庫上傳gitee(github,gitlab)遠程倉庫,而遠程分支不是一個空項目,此時相當于兩個不同項目合并,本地合并兩個不同的項目;
## 相關指令:
* [git fetch](http://www.hmoore.net/wteamxq/git_rank/277281) 更新代碼(不合并本地修改)指令: 雖然大師說[少用git pull多用git fetch](http://www.oschina.net/translate/git-fetch-and-merge), 實際上大家還是只用`git pull`忘了有我這個`git fetch`;
* [git_merge.md](http://www.hmoore.net/wteamxq/git_rank/276600) 合并分支指令:`git pull`是領導, 活兒都是我們干的!誒! 這評論區是匿名的吧?