【Git】---git fetch命令
阿新 • • 發佈:2018-12-22
語法
git fetch [<options>] [<repository> [<refspec>…]] git fetch [<options>] <group> git fetch --multiple [<options>] [(<repository> | <group>)…] git fetch --all [<options>]
描述
官方描述:從另一個倉庫中下載物件和引用。
筆者解讀:當需要將遠端倉庫中的更新取回本地時,使用 git fetch 命令。
引數
<repository>
The "remote" repository that is the source of a fetch or pull operation. 即遠端倉庫的名字。
<refspec>…
Specifies which refs to fetch and which local refs to update. 格式為 <src>:<dst>,即指明遠端分支和本地分支的名字。
例子
1.取回遠端跟蹤分支的更新
$ git fetch origin
省略了 refspec 引數,作用是從 遠端倉庫origin 中將所有分支的更新取回本地。如果未指定遠端倉庫名稱,預設使用 origin 。
2.取回特定分支的更新
$ git fetch origin master:master
將遠端倉庫origin中分支master的跟新取回到本地分支master中。