Git高级命令

2020-04-14  本文已影响0人  莫忘初心_倒霉熊

Git sparse-checkout 检出指定目录或文件

# 设置允许git克隆子目录
git config core.sparsecheckout true

# 创建本地空repo
git init myRepo && cd myRepo

# 设置要克隆的仓库的子目录路径, “*” 是通配符,“!” 是反选
echo deployment/ >> .git/info/sparse-checkout

# 设置远程仓库地址
git remote add origin ssh://github.com/abc.git

# 用 pull 来拉取代码
git pull origin master

#############################

# 如果需要添加目录,就增加sparse-checkout的配置,再checkout master
echo another_folder/ >> .git/info/sparse-checkout
git checkout master
上一篇 下一篇

猜你喜欢

热点阅读