How to Create a Folder in GitHub (Step by Step)


GitHub how to create a folder
XINSTALL BY CLICKING THE DOWNLOAD FILE
A message from our partner

For fixing Windows errors, we recommend Fortect:

Fortect will identify and deploy the correct fix for your Windows errors. Follow the 3 easy steps to get rid of Windows errors:

  • Download Fortect and install it on your PC
  • Launch the tool and Start scanning your PC for Windows errors
  • Right-click on Start Repair to deploy the right fix for each error encountered during the scan
Download Now Fortect has been downloaded by 0 readers this month, rated 4.6 on TrustPilot

Creating folders in GitHub helps you keep files organized and your projects easier to manage. You can set them up directly on the GitHub website or from your local computer using Git commands. Here’s a step by step guide to help you create a folder in GitHub.

How to Make a Folder in GitHub?

1. Create a Folder on GitHub Website

The simplest way to make a folder is from the GitHub interface itself.

  1. Open your GitHub repository
  2. Click Add file and select Create new file

  3. In the file name field, type the folder name followed by a slash, for example docs/README.md
  4. Add some content to the file and click Commit new file

This creates a folder instantly and places the file inside it. For other essential tasks, you might also want to learn how to delete a branch in GitHub.

2. Create a Folder Locally with Git

If you prefer more control, you can create folders on your local machine and then push them to GitHub.

  1. Open your terminal or command prompt
  2. Navigate to your repository with:
    cd repo-name
  3. Create a new folder with:
    mkdir folder-name
  4. Place a file inside the folder with:
    touch folder-name/README.md
  5. Save and push the changes:
    git add .
    git commit -m "Added folder"
    git push

GitHub does not recognize empty folders, so adding at least one file is necessary. While working locally, it can also help to know how to merge branches in GitHub.

When working with local repositories and pushing changes, you may sometimes run into merge issues. For detailed steps on fixing them, see how to resolve conflicts in GitHub.

After you push the new folder to the remote, the next step is often a code review in a pull request, so learn how to approve a pull request on GitHub to complete the workflow.

You may also want to change the default branch in GitHub to ensure new pull requests and commits target the right line of development; see this step by step guide on how to change the default branch in GitHub.

Why GitHub Requires a File

Git is designed to track files rather than empty directories. This is why a folder only shows up in your repository if it contains something inside. Developers often add placeholder files such as .gitkeep or README.md to make sure their folders remain visible. If you ever need the reverse process, check this guide on how to download a folder from GitHub.

FAQs

How do I create multiple folders in GitHub?

You can type slashes in the file path, for example src/components/button/index.js, and GitHub will create all the necessary folders automatically.

Can I add an empty folder in GitHub?

No. A folder must have at least one file for GitHub to display it.

Which method is best for creating folders?

The website method is easiest for quick changes, while using Git locally gives you more flexibility.

Can I rename a folder in GitHub?

Yes. You can move the files into a new folder with the name you want, then remove the old one.

Conclusion

Making folders in GitHub is straightforward once you know the steps. The website option is quick for small adjustments, while creating folders locally is better for project work. No matter which method you choose, remember that every folder needs a file inside to be stored properly.

More about the topics: folder, Github

Readers help support Windows Report. We may get a commission if you buy through our links. Tooltip Icon

Read our disclosure page to find out how can you help Windows Report sustain the editorial team. Read more

User forum

0 messages