Home > Development Tools > git > body text

How to download only the contents of one folder in github

PHPz
Release: 2023-03-27 11:29:31
Original
5471 people have browsed it

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]
Copy after login

For example:

git clone https://github.com/username/repository-name.git
Copy after login

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
Copy after login

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]
Copy after login

For example:

svn export https://github.com/username/repository-name/trunk/folder1 folder1
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template