Download required folder only from GitHub

Download required folder only from GitHub

Hello pals, We've all been in a situation where we needed to download a folder from GitHub but were forced to clone an entire large repository before we could access the required folder. Well, there's no more reason to fear or worry about these situations. This blog tutorial will show you how to download only the required folder from GitHub without cloning the entire repository.

Navigate the repository and directory you want

First of all, navigate to the repository from which you want to access the folder. Here, I am taking my Machine Learning repository as an example.

ML Repo

Then, I am navigating to the directory named data-visualization which I want to download. Then copy the URL from the browser address bar which is https://github.com/theArjun/machine-learning/tree/master/data-visualization in my case. Note this or get it stored in the clipboard.

Data Visualization Repo

Install Subversion

I am using subversion to download the required directory. Make sure you have it installed on your system before proceeding.
apt-get install subversion

Tweak URL

I hope you’ve noted the directory URL from GitHub or got it stored on your clipboard, which was https://github.com/theArjun/machine-learning/tree/master/data-visualization in my case. Now replace the tree/master with trunk which results in https://github.com/theArjun/machine-learning/trunk/data-visualization and note it again. Good going, pals, We’re now at the final stage.

Download the Directory

Launch the terminal and type the following command:
svn checkout https://github.com/theArjun/machine-learning/trunk/data-visualization

The URL was the tweaked URL that I instructed in the Tweak URL section. The execution of the command looks like the following in the terminal.

$ svn checkout https://github.com/theArjun/machine-learning/trunk/data-visualization

A    data-visualization/Data Generation - Classification.ipynb
A    data-visualization/Data Generation - Regression Data.ipynb
A    data-visualization/Data Normalization and Standardization.ipynb
A    data-visualization/Data Visualization - Subplots.ipynb
A    data-visualization/Exploring Sklearn Datasets.ipynb
A    data-visualization/Generating Data using Sk-Learn.ipynb
A    data-visualization/Matplotlib Basics.ipynb
A    data-visualization/Multivariate Normal Distribution  .ipynb
A    data-visualization/Normal Distribution & Histogram.ipynb
A    data-visualization/Numeric Spacing.ipynb
A    data-visualization/PyCharts, BarCharts and Legends.ipynb
A    data-visualization/Template.ipynb
A    data-visualization/Working with Pandas - MNIST Dataset.ipynb
A    data-visualization/Working with Pandas.ipynb
A    data-visualization/csv
A    data-visualization/csv/linearX.csv
A    data-visualization/csv/linearY.csv
A    data-visualization/csv/movie_data.csv
Checked out revision 103.

and a directory named data-visualization gets created in the working folder.

$ ls

data-visualization

This folder contains all the files that are in the data-visualization folder on GitHub, i.e., files that are synced with the remote (GitHub).

So, no worries, create as many folders as you need and download them as required without cloning the whole bulky repository.

Thanks for reading.