Download required folder only from GitHub with Subversion
Tags: github, download, directory, git
Published: 2020-05-03 16:51:29


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](https://github.com/theArjun/machine-learning) repository as example. 

![ML Repo](https://i.ibb.co/W3c5Gd1/image.png)

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](https://github.com/theArjun/machine-learning/tree/master/data-visualization) in my case. Note this or get it stored in clipboard.

![Data Visualization Repo](https://i.ibb.co/WB5XBGf/image.png)
## 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

## 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](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](https://github.com/theArjun/machine-learning/tree/master/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

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.
```
and a directory named data-visualization gets created on the working folder. 

```
$ ls

data-visualization
```
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 :) `.