GitHub is a popular code hosting platform for developer collaboration and version control. As a developer, you may need to download only the contents of a specific folder from another developer's GitHub repository. In this article, we will demonstrate how to download only a folder in a GitHub repository without downloading the entire repository.
Step 1: Open the GitHub repository
First, open the GitHub repository and find the folder you want to download. Click the green Clone or Download button above the folder.
Step 2: Copy the repo URL
The pop-up option box shows the clone URL that can be used. Here, find the HTTPS or SSH URL and click the copy button.
Step 3: Use the git clone command in the command line
Open the command line terminal and use the git clone command to clone the repository to the local computer. In the terminal, type the following command, pasting the URL you copied earlier:
git clone [repo URL]
For example:
git clone https://github.com/username/repository-name.git
Press Enter to start downloading the repository.
Step 4: Download only the required folder
After downloading the complete repository, use the cd command to enter the directory where the repository is located. For example:
cd repository-name
Then, use the following command to download only the required folders. In the following command, replace [folder-name] with the name of the folder you want to download.
svn export https://github.com/username/repository-name/trunk/[folder-name] [folder-name]
For example:
svn export https://github.com/username/repository-name/trunk/folder1 folder1
This command will download a specific folder of the repository to the specified location on your local computer. In this example, it is folder1.
Step Five: Complete Download
After completing the command, go to the downloaded folder and check if it contains only the required files and subfolders. You can also delete unnecessary files and subfolders.
Summary
Using these simple steps, you can quickly and easily download only the contents of a specific folder in your GitHub repository. This allows you to access and develop the code you need faster and reduces the tedious process of downloading the entire repository.
The above is the detailed content of How to download only the contents of one folder in github. For more information, please follow other related articles on the PHP Chinese website!