语法
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中。