开发的mac机器只有256G的硬盘,工程代码仓库 clone
下来后少的10几G,大的有60多G, 所以在日常的使用中,经常会遇到磁盘空间不足的问题,头痛不已。
我们是跨平台开发,git仓库中会保存mac/linux两个平台所需要的所有文件。 其中 *.so
等一些文件在开发mac工程时是不需要的,可以使用sparse checkout功能在同步远程仓库时候,不拉取这些文件,给磁盘留出多一些的可用空间。
可以执行如下命令,只拉取指定的目录下内容
$ git init <project>
$ cd <project>
$ git remote add origin https://*****.git // 你的git仓库地址
$ git config core.sparsecheckout true
$ echo "path1/" >> .git/info/sparse-checkout
$ echo "path2/" >> .git/info/sparse-checkout
$ git pull origin [branch] // 你的分支名称
git init <project>
: 建立一个空的版本库git remote add origin https://*****.git
: 添加远程库的地址git config core.sparsecheckout true
: 打开sparse checkout功能echo "path1/" >> .git/info/sparse-checkout
: 添加目录到checkout的列表 ,也可以使用文本编辑git pull origin [branch]
: 拉取远程的分支$ git config core.sparsecheckout true
.git/config
配置文件中可以看到新增了 sparsecheckout = true
的配置
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
sparsecheckout = true
.git/info/sparse-checkout
文件 (没有这个文件可以手动创建一个)
添加如下列表。/*
!/add_on/native_addon/kylinv4_ft1500a/*
!/add_on/native_addon/neokylin_lib/*
!/add_on/native_addon/ubuntu_lib/*
!/add_on/native_addon/uos_arm_lib/*
!*.so
$ git checkout [branch] // 你的分支名称
or
$ git read-tree -mu HEAD
*.so
!/docs/
要注意一点:关闭sparsecheckout功能,全取整个项目库,可以写一个”“号,但如果有排除项,必须写”/“,同时排除项要写在通配符后面。