zoukankan      html  css  js  c++  java
  • Git sparse-checkout 检出指定目录或文件

    根据网上资料整理而来,git 1.7版本后支持的sparse checkout特性,可以指定需要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

    后来上面方法遇到错误

    error: Sparse checkout leaves no entry on working directory

    ,又找到另一种方法如下。最后发现,如果在shell里执行,sparse-checkout 里的路径需要最后加*,但是如果是git-prompt,则可以不需要最后的/*.

    git clone -n https://github.com/tensorflow/models
    cd tensorflow
    git config core.sparsecheckout true
    echo official/resnet/* >> .git/info/sparse-checkout
    git checkout master
  • 相关阅读:
    Python解释器相关知识
    简单了解下Flask
    Scoket编程
    __file__的作用
    jquery编写可折叠列表
    浑浑噩噩的一天
    js实现杨辉三角
    js闭包
    python读取word表格
    HTMLTestRunner报告
  • 原文地址:https://www.cnblogs.com/pekkle/p/9742393.html
Copyright © 2011-2022 走看看