docs(git): add advanced and error

This commit is contained in:
zjkjzj
2021-03-18 20:08:24 +08:00
parent 967b4b575d
commit 481904f1dc
39 changed files with 1820 additions and 2 deletions

View File

@@ -0,0 +1,37 @@
# 拉取指定远程分支到本地
由于`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)