How to Create a Folder Inside a Repository on GitHub

GitHub provides a user-friendly interface for managing your repositories directly from the web — including the ability to create folders (also known as directories) without needing to use Git or the command line.

In this guide, you’ll learn how to create a new folder inside a GitHub repository using the GitHub website.


✅ Step-by-Step: Create a Folder in GitHub Repository

🔹 Step 1: Navigate to the Repository

  1. Go to https://github.com.
  2. Navigate to your desired repository.

🔹 Step 2: Create a New File

  1. Inside the repository, click the “Add file” dropdown.
  2. Select “Create new file”.

🔹 Step 3: Use Slash / to Create a Folder

In the filename input box:

folder-name/filename.txt

Example:

docs/readme.md

This will:

  • Automatically create a folder called docs
  • Create a file named readme.md inside it

Note: GitHub does not allow creating empty folders. A folder must contain at least one file to exist in the repository.


🔹 Step 4: Commit the New File

  1. Scroll down to the “Commit new file” section.
  2. Add a commit message like "Add docs folder with readme.md".
  3. Choose whether to commit to the main branch or create a new branch.
  4. Click “Commit new file”.

📁 Tip: Create Nested Folders

You can create multiple nested folders by adding more slashes:

folder1/folder2/folder3/filename.md

GitHub will create the full folder structure automatically.


✅ Summary

TaskHow to Do It
Create a folderUse folder-name/filename.ext format
Create nested foldersUse folder1/folder2/filename.ext
Commit fileAdd a message and click “Commit”
Cannot create empty folderMust include at least one file

🚀 Final Thoughts

While GitHub doesn’t support empty folders, its intuitive file creation feature makes organizing your repository simple. By naming a file with slashes (/), you can build a structured folder system to keep your project organized and readable.

Sharing Is Caring:

Leave a Comment