DEV Community

Arjun Adhikari
Arjun Adhikari

Posted on • Updated on

Download required folder only from GitHub with Subversion

Hello pals,
We all have experienced a situation where we need to download a folder from GitHub but we are forced to clone a whole bulky repository and then access the required folder. Well, no more reason to fear to worry of these situations. Through this blog tutorial I'm going to guide you to download only the required folder from GitHub without cloning the whole repository.

Navigate the repository and directory you want

First of all, navigate to the repository you want to access the folder. Here, I am taking my Machine Learning repository as 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 clipboard.

Data Visualization Repo

Install Subversion

I am using subversion to download the required directory. For doing so, make sure you've installed it on your system.

apt-get install subversion
Enter fullscreen mode Exit fullscreen mode

Tweak URL

I hope you've noted the directory URL from GitHub or get it stored on 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 to 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

Open the terminal and execute the following command :

svn checkout https://github.com/theArjun/machine-learning/trunk/data-visualization
Enter fullscreen mode Exit fullscreen mode

The URL was the tweaked URL which I guided in Tweak URL section. The execution of command looks like following in 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.
Enter fullscreen mode Exit fullscreen mode

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

$ ls

data-visualization
Enter fullscreen mode Exit fullscreen mode

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

So, no worries, create as many folders you need and download them as required without cloning whole bulky repository.
I hope you enjoyed learning a new trick. I will be back with similar tricks soon. Till then keep coding :).

Top comments (1)

Collapse
 
shalujha profile image
shalujha

It was really helpful.. waiting for ur next blog!!🔥🔥