GitHub has been a code repository of choice for many of the popular open-source projects that power many of the enterprise applications. Anybody can sign up for free and start downloading any project that they want as long as they have access to its repository. In this post, I am going to show you how you can interact with GitHub. I will show you how you can download a file, a folder, or a whole project from any GitHub repository.
If you want to see a demo of this project in raw video format then please see the below video or watch it on my YouTube channel.
How to download a GitHub folder?
Sometimes, a GitHub repository contains lots of files and directories and you are only interested in downloading a particular folder. So what can you do about this? Let us look at an example repository of mine.
For example, my PlatformIO project repository contains self-contained independent project folders that I am grouping per each blog that I am creating.
If you are interested in downloading only a certain folder then do the following:
- Locate the name of the folder that you want to download by clicking the folder name and take note of the URL above. In my case, below is the name of the folder that I want to download.
- Next, navigate to the following site (https://download-directory.github.io/) and paste the URL that you copied in the step above. Press enter.
- After that, it will automatically download the folder in a zip format. You then can use any unzipping utility program like 7-Zip or Winrar if you are on Windows/PC.
- Verify the downloaded zip file and open it on your favorite code editor.
How to download a GitHub project or repository?
If you have no issues about downloading the whole GitHub project or repository and you want to have a local copy of the whole project on your workstation then you can do the following.
Option 1 – Download the Zip File of the project
- Go to the GitHub root page of the project that you want to download. Click the Code button link and Download as Zip file menu.
- Verify the downloaded project by unzipping it and opening it in your favorite code editor.
Option 2 – Download using Git
Another popular option for downloading GitHub projects or repositories is by using the Git client. The formal term is cloning the GitHub repository as you now will be having a local copy of the GitHub project on your workstation. You can even update the code and commit it back to GitHub if you have access. You can follow the steps below on how to clone GitHub repositories.
- Download and Install Git client for your own operating system. Some of the Linux distributions have Git preinstalled so you don’t need to install anything but if you don’t have one installed then just go to this site and download the appropriate clients for you and follow the installation steps.
- Open a terminal or a Git bash terminal if you are on Windows/PC and locate a folder where you want to download the GitHub project or repository. You can also use a command terminal prompt on Windows/PC.
- Go to the GitHub repository and copy the Git endpoint of the project that you want to download.
- On your terminal, type in the following code.
git clone https://github.com/donskytech/platformio-projects.git
Open the same project on your favorite code editor as it is now downloaded into your workstation file system.
How to download a GitHub file?
Lastly, If you only want to download a specific GitHub file and you don’t want to download the whole project repository or download the specific folder then you can do the following.
- Navigate to the GitHub project repository and click the Go To File button.
- In the right-hand side of the File Search section, type in the name of the file that you want to see or download. In my case, I am searching for a file with the name “OLED” and it would give me the list of files that match my search terms. Click the file that you want to view.
- GitHub will show you the content of the file that you have selected. If you want to save the file to your local file system then you can either click the Raw or Copy or Download the raw file option at the top of the file.
In this post, I have shown you several options on how you can download GitHub files and folders from any GitHub repository. As more and more projects are getting added to GitHub then it is equally important to know how to interact with it. So what exciting and cool projects are you going to create with GitHub?
I love sharing what I know and hopefully, I was able to help you. Writing helpful content takes so much time and research. If you think you like my work and I have managed to help you then please consider supporting my channel. I would be very grateful and would boost my confidence that what I am doing is making a big change in the world. (No Pun Intended!) 😉Become a Patron!