Download subfolders and individual files of a project on Github

preface

  The project under Github may be very large, and there are many subfolders in it. We may only need to use the resources in a subdirectory, which can be used without downloading the complete repo.

  For example, I want to download the dictionary files in this repo: https://github.com/starnightcyber/findSubDomains/tree/master/dict

install svn

sudo apt-get install subversion

download subdirectory

  Click to enter the dict we want to download, the url address is: https://github.com/starnightcyber/findSubDomains/ tree/master /dict

  Replace tree/master with trunk, i.e. https://github.com/starnightcyber/findSubDomains/trunk/dict

  Use the command as follows:

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

  In this way, we have downloaded the dictionary dict we only need to use. This method is especially convenient when the project is large and the network speed is not strong.

Download a single file

  The method mentioned above is only suitable for downloading subdirectories, and cannot be used for downloading individual files

  For example I want to download this file: https://github.com/starnightcyber/findSubDomains/blob/master/dict/subnames.txt

  First click raw ->

  Address bar jump: https://raw.githubusercontent.com/starnightcyber/findSubDomains/master/dict/subnames.txt

  In this way, you can download the tool wget through the commonly used command line:

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

  We can see that subnames.txt has been downloaded locally.

   

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325826012&siteId=291194637