码迷,mamicode.com
首页 > 其他好文 > 详细

git拉取单个目录

时间:2018-03-28 20:36:51      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:conf   地址   blog   line   str   ops   dex   plain   .com   

有时git库里的东西比较多,我们只希望像SVN一样,只拉取git库的一个目录。
例如:基础代码仓库infra-code_ops有很多基础代码,我们只想拉取仓库里nginx-conf目录的文件。
$ git init infra-code_ops-nginx && cd  infra-code_ops-nginx          //初始化仓库,并进入该目录
$ git remote add -f origin http://gitlab.xxx.com/ops/infra-code_ops.git   //添加远程仓库地址
$ git config core.sparsecheckout true    //开启sparse checkout功能
$ echo "nginx-conf/" >> .git/info/sparse-checkout   //将nginx-conf/目录写入到该文件中
$ cat .git/info/sparse-checkout   //确认查看该文件内容
$ git pull origin master    //拉取远程master分支

git拉取单个目录

标签:conf   地址   blog   line   str   ops   dex   plain   .com   

原文地址:https://www.cnblogs.com/elisun/p/8665550.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!