[转]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中的确 ...
随机推荐
- (网络流 模板)A Plug for UNIX -- poj -- 1087
链接: http://poj.org/problem?id=1087 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82835#probl ...
- AQS详解(AbstractQueuedSynchronizer)
Intrinsic VS explicity 1. 不一定保证公平 1. 提供公平和非公平的选择 2. 无 2. 提供超时的 ...
- cordova3.X-4.0添加自定义插件方法
cordova3.X之后,插件不能自己手动添加了,手动添加后,只要cordova build,数据立即被抹去. 因此,3.X后要添加插件,需要用 cordova plungin add "你 ...
- paip.双网卡多网卡不能上网的联网配置
paip.双网卡多网卡不能上网的联网配置 作者Attilax , EMAIL:1466519819@qq.com 来源:attilax的专栏 地址:http://blog.csdn.net/att ...
- MDX示例:求解中位数、四分位数(median、quartile)
一个人力资源咨询集团通过网络爬虫采集手段将多个知名招聘网站上发布的求职和招聘等信息准实时采集到自己的库里,形成一个数据量浩大的招聘信息库,跟踪全国招聘和求职的行业.工种.职位.待遇等信息,并通过商业智 ...
- [ajax] quick double or multiple click ajax submit cause chrome explorer's error snatshot
快速点击ajax提交,引发的错误截图1: snapshot -2:
- 如何充分利用 Windows Phone 高清屏幕
Nokia 最近发布两款6寸大屏手机:Lumia 1520 和 Lumia 1320.为了支持这种设备 WP 升级了操作系统GDR3 支持了 1080P 的高清分辨率(1520),虽然GER3 是提供 ...
- 二、安装并配置Kubernetes Master节点
1. 安装配置Master节点上的Kubernetes服务 1.1 安装Master节点上的Kubernetes服务 yum -y install kubernetes 1.2 修改kube-apis ...
- 跨终端Web
1.终端vs设备 H5页面运行在同一设备的不同终端下. (1)Web浏览器. (2)微信.QQ浏览器. (3)移动App的Webview. (4)TV机顶盒. 2.跨终端的实现方式 (1)响应式 存在 ...
- LeetCode141:Linked List Cycle
题目: Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without usin ...