mirror of
https://github.com/ZJDoc/GitGuide.git
synced 2026-07-29 15:20:25 +08:00
37 lines
765 B
Markdown
37 lines
765 B
Markdown
|
|
# 拉取指定远程分支到本地
|
|
|
|
由于`git`去中心化的特性,下载远程仓库时会将所有分支都下载下来,不仅耗时而且占用本地磁盘容量。拉取指定远程分支到本地
|
|
|
|
## 思路
|
|
|
|
* 首先在本地新建`git`仓库;
|
|
* 然后下载指定远程分支;
|
|
* 最后创建本地分支并关联到指定远程分支即可。
|
|
|
|
## 实现
|
|
|
|
新建仓库
|
|
|
|
```
|
|
$ mkdir gitrepo
|
|
$ cd giterpo
|
|
$ git init
|
|
```
|
|
|
|
拉取远程指定分支
|
|
|
|
```
|
|
$ git remote add origin https://github.com/zjZSTU/zjzstu.github.com.git
|
|
$ git fetch origin dev
|
|
```
|
|
|
|
新建本地分支并关联到指定远程分支
|
|
|
|
```
|
|
$ git checkout -b dev origin/dev
|
|
```
|
|
|
|
## 相关阅读
|
|
|
|
* [git 拉取远程分支到本地](https://blog.csdn.net/carfge/article/details/79691360) |