zoukankan      html  css  js  c++  java
  • 下载Github上某个项目的子文件夹和单个文件

    preface

      Github下的项目可能很大,里面有很多的子文件夹,我们可能只需要使用某个子目录下的资源,可以不用下载完整的repo就能使用。

      例如,我想下载这个repo中的字典文件:https://github.com/starnightcyber/findSubDomains/tree/master/dict

    安装svn

    sudo apt-get install subversion

    下载子目录

      点击进入我们要下载的dict,url地址为:https://github.com/starnightcyber/findSubDomains/tree/master/dict

      将tree/master用trunk替换,即https://github.com/starnightcyber/findSubDomains/trunk/dict

      使用命令如下:

    root@ubuntu-s-1vcpu-1gb-sfo2-01:~/starnight# svn checkout https://github.com/starnightcyber/findSubDomains/trunk/dict
    A    dict/dns_servers.txt
    A    dict/next_sub.txt
    A    dict/next_sub_full.txt
    A    dict/subnames.txt
    A    dict/subnames_full.txt
    Checked out revision 17.
    root@ubuntu-s-1vcpu-1gb-sfo2-01:~/starnight# ls
    dict

      这样,我们就下载好了我们只需要使用的字典dict,这种方式尤其是在项目很大的时候,而网速有不给力的情况下,特别方便。

    下载单个文件

      上面提到的方法只适合于下载子目录,并不能用于下载单个文件

      比如我要下载这个文件: https://github.com/starnightcyber/findSubDomains/blob/master/dict/subnames.txt

      先点击raw ->

      地址栏跳转:https://raw.githubusercontent.com/starnightcyber/findSubDomains/master/dict/subnames.txt

      这样就能通过常用的命令行下载工具wget了:

    root@ubuntu-s-1vcpu-1gb-sfo2-01:~/starnight# wget https://raw.githubusercontent.com/starnightcyber/findSubDomains/master/dict/subnames.txt
    --2018-05-08 08:19:34--  https://raw.githubusercontent.com/starnightcyber/findSubDomains/master/dict/subnames.txt
    Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.40.133
    Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.40.133|:443... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 123827 (121K) [text/plain]
    Saving to: ‘subnames.txt’
    
    subnames.txt                        100%[================================================================>] 120.92K  --.-KB/s    in 0.01s
    
    2018-05-08 08:19:34 (12.3 MB/s) - ‘subnames.txt’ saved [123827/123827]
    
    root@ubuntu-s-1vcpu-1gb-sfo2-01:~/starnight# ls
    dict  subnames.txt

      我们可以看到subnames.txt已经下载到本地了。

       

  • 相关阅读:
    Android 剪贴板详解
    Android 7.1
    Windows 上安装 Redis 及可能出现的错误和解决方法!
    微信支付(服务商模式问题集)
    LOG4J日志问题 Failed to load class "org.slf4j.impl.StaticLoggerBinder".
    Mysql强制修改密码
    Mysql密码忘记,修改密码方法
    笔记本最大支持内存查看方法
    Liunx操作指令搜素引擎
    tomcat启动时,内存溢出,Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "main"
  • 原文地址:https://www.cnblogs.com/Hi-blog/p/How-To-Download-SubDirectory-or-Single-File-From-Github-Repo.html
Copyright © 2011-2022 走看看