[转]Subdirectory Checkouts with git sparse-checkout
From:http://jasonkarns.com/blog/subdirectory-checkouts-with-git-sparse-checkout/
If there is one thing I miss about SVN having switched to git (and trust me, it’s the only thing), it is the ability to checkout only a sub-tree of a repository. As of version 1.7, you can check out just a sub-tree in git as well! Now not only does git support checking out sub-directories, it does it better than subversion!
New Repository
There is a bit of a catch-22 when doing a sub-tree checkout for a new repository. In order to only checkout a sub-tree, you’ll need to have the core.sparsecheckout option set to true. Of course, you need to have a git repository before you can enable sparse-checkout. So, rather than doing a git clone, you’ll need to start with git init.
Create and initialize your new repository:
mkdir <repo> && cd <repo>
git init
git remote add –f <name> <url>Enable sparse-checkout:
git config core.sparsecheckout true
Configure sparse-checkout by listing your desired sub-trees in .git/info/sparse-checkout:
echo some/dir/ >> .git/info/sparse-checkout
echo another/sub/tree >> .git/info/sparse-checkoutCheckout from the remote:
git pull <remote> <branch>
Existing Repository
If you already have a repository, simply enable and configure sparse-checkout as above and do git read-tree.
Enable sparse-checkout:
git config core.sparsecheckout true
Configure sparse-checkout by listing your desired sub-trees in .git/info/sparse-checkout:
echo some/dir/ >> .git/info/sparse-checkout
echo another/sub/tree >> .git/info/sparse-checkoutUpdate your working tree:
git read-tree -mu HEAD
Modifying sparse-checkout sub-trees
If you later decide to change which directories you would like checked out, simply edit the sparse-checkout file and run git read-tree again as above.
Be sure to read the documentation on read-tree/sparse-checkout. The sparse-tree file accepts file patterns similar to .gitignore. It also accepts negations—enabling you to specify certain directories or files to not checkout.
Now there isn’t anything that svn does better than git!
[转]Subdirectory Checkouts with git sparse-checkout的更多相关文章
- Git sparse checkout
Git的sparse checkout在clone项目仓库时只clone指定路径下的信息. 步骤如下: (1) mkdir yourdir(2) cd yourdir(3) git init(4) g ...
- 使用Sparse Checkout 排除跟踪Git仓库中指定的目录或文件
应用场景 在一个大工程里包含由不同部门开发的模块时,项目的Git仓库肯定很大,造成每次Git操作相对比较耗时.因为开发人员一般只关心他们部门的模块的代码,所以完全可以排除一些他完全不需要用到的目录.这 ...
- git branch & checkout fetch 的使用和冲突解决
git branch & checkout fetch 的使用和冲突解决 branch git branch 查看本地分支 git branch -v 查看本地分支的具体信息(commi ...
- TortoiseSVN 只取下或更新部分文件的方法(Sparse Update/Sparse Checkout)
Sparse Update/Sparse Checkout To easily select only the items you want for the checkout and force ...
- Git的checkout, reset, revert
不管是修改还是新建文件,都必须通过git add把这次修改从工作区加到暂存区: commit只是提交暂存区的修改,还没add到暂存区处于工作区的修改是不会commit的: git checkout ...
- 在 Git 中 Checkout 历史版本
昨天写代码的时候,误删了一个文件.今天发现的时候,commit 已经 push 到版本库了.本想用 git reset 回退版本,找回文件后重新提交.但是想起 Git 是一个版本控制系统哎,直接从版本 ...
- Git CMD - checkout: Switch branches or restore working tree files
命令格式 git checkout [-q] [-f] [-m] [<branch>] git checkout [-q] [-f] [-m] --detach [<branch&g ...
- Git单独checkout子目录
http://schacon.github.io/git/git-read-tree.html#_sparse_checkout Existing Repository If you already ...
- git使用中checkout生成临时br的问题(吓出一身冷汗啊)
git中几天前漫不经心的使用了git checkout ver_hash的命令,结果push到远程库都提示everything is up-to-date,实际神马都没提交上去啊!但看本地log中的确 ...
随机推荐
- POJ 3621 Sightseeing Cows (bellman-Ford + 01分数规划)
题意:给出 n 个点 m 条有向边,要求选出一个环,使得这上面 点权和/边权和 最大. 析:同样转成是01分数规划的形式,F / L 要这个值最大,也就是 G(r) = F - L * r 这个值为0 ...
- event对象的clientX,offsetX,screenX,pageX和offsetTop,offsetHeight等等
先总结下区别: event.clientX.event.clientY 鼠标相对于浏览器窗口可视区域的X,Y坐标(窗口坐标),可视区域不包括工具栏和滚动条.IE事件和标准事件都定义了这2个属性 eve ...
- QGIS+GH + MapServer
拒绝描图,如何利用GH+QGIS完爆场地底图?http://www.sohu.com/a/251004986_657084 拒绝描图--爬取OSM数据绘制底图 所用软件 RHINO+GH\QGIS\G ...
- python的特性
python使用c语言开发 1.面向对象的特性 面向对象的程序设计抽象出对象的行为和属性,把行为和属性分离开,但是又合理的组织在一起.它消除了保护类型.抽象类.接口等面向对象的元素,使得面向对象的概念 ...
- Vuejs——(5)v-on
版权声明:出处http://blog.csdn.net/qq20004604 目录(?)[+] 资料来于官方文档: http://cn.vuejs.org/guide/events.html ...
- REST格式
首先要明确一点:REST 实际上只是一种设计风格,它并不是标准.(所以你可以看到网上一大堆的各种最佳实践,设计指南,但是没有人说设计标准).aisuhua/restful-api-design-ref ...
- maven下@override标签失效
经常遇见此问题,现记录如下,以备下次查阅. 在pom文件添加配置: <plugin> <groupId>org.apache.maven.plugins</groupId ...
- 发展科技到底有什么用,转NASA专家给一位修女的一封信
问题补充:我们难道不应该把这些资金用于更深入的医疗保障和减少贫穷吗? 我们为何要仰望星空,花大量的金钱和精力探索那不可预知的宇宙呢?NASA科学家写给非洲修女的一封信回答得特别好,也特别震撼人心.—— ...
- EasyUi TreeGrid/DataGrid getChecked BUG
问题描述 步骤一,选中左边树一个节点,然后出现相应的数据,选中进行保存.如,我选中了前4个节点,上图: 步骤二,我再选tree中第二个节点,进行相应的选中和取消选中treegrid中的节点,并保存. ...
- 你好,Azure DevOps Server 2019;再见,Team Foundation Server
微软正式发布Azure DevOps Server 2019的第一个版本,作为Team Foundation Server (TFS)2018的升级版本和替代产品. 这是目前市面上唯一一款将产品名称冠 ...