GitHub doesn't let you create empty folders, but you can create one by adding a file inside it
GitHub's web interface does not have a button to create a folder by itself. Folders only exist in GitHub when they contain at least one file. The fastest way to create a folder is to add a file to your repository and put it inside a new folder path — GitHub creates the folder structure automatically.
This works whether you are starting a new repository or adding folders to an existing one. You do not need to use the command line or any special tools. The process takes about two minutes through the GitHub website.
Key Takeaways
- GitHub creates folders automatically when you add a file with a forward slash in its path, like foldername/filename.txt.
- You can create nested folders (folders inside folders) by using multiple forward slashes in the file path, like folder1/folder2/filename.txt.
- Empty folders cannot be stored in GitHub, so every folder must contain at least one file.
- You can add a placeholder file like .gitkeep to hold a folder in place if you do not yet have real content for it.
Creating a single folder with a file inside
Open your repository on GitHub and click the Add file button near the top right. Select Create new file from the dropdown menu.
In the filename field at the top, type the folder name followed by a forward slash, then the filename. For example, if you want a folder called docs with a file called readme.txt inside it, type docs/readme.txt. GitHub will create the docs folder automatically when you save.
Add whatever content you want in the file (or leave it blank), scroll down, and click Commit changes. GitHub creates the folder and the file at the same time.
Creating nested folders (folders inside folders)
Use the same process, but add multiple forward slashes to create deeper folder structures. If you type src/components/buttons/button.js, GitHub creates three folders: src, then components inside it, then buttons inside that, and finally the file button.js at the end.
You can create as many folder levels as you need in a single step. This is useful when you are setting up a project structure all at once without having to create each folder one by one.
Using .gitkeep to hold an empty folder
If you need a folder to exist but do not have a file to put in it yet, create a file called .gitkeep inside it. This is a placeholder file that developers use to keep folders in place. Type the folder path followed by .gitkeep, like images/.gitkeep, then commit it.
The .gitkeep file is invisible in most GitHub views and does not affect your project. When you are ready to add real files to that folder, you can delete .gitkeep or leave it there — it will not cause any problems either way.
Creating folders through the upload feature
If you already have files on your computer that you want to organize into folders, you can upload them and create the folder structure at the same time. Click Add file and select Upload files.
Drag your files into the upload area. Before you commit, look at the file paths shown on the page. If you want to organize them into a folder, you can edit the path for each file to add a folder name at the beginning. For example, change myfile.txt to documents/myfile.txt and GitHub will place it in a documents folder.
What happens if you try to create an empty folder
If you navigate to your repository and try to create a folder without putting a file in it, GitHub will not save it. The folder will disappear as soon as you try to commit because Git (the system GitHub uses) does not track empty directories. This is a limitation of how Git works, not a GitHub limitation.
This is why the .gitkeep workaround exists — it gives the folder something to hold onto. Once you add a real file to the folder later, you can remove .gitkeep if you want.
Organizing an existing repository with new folders
If your repository already has files scattered at the top level and you want to organize them into folders, you cannot move files through the GitHub web interface. You have two options: use the command line to move files locally and push the changes, or delete and re-upload files with new folder paths.
For most people, the re-upload method is simpler. Delete the files you want to move, then use the upload feature to add them back with the folder path included in the filename. GitHub will create the folder and place the files inside it.
Frequently Asked Questions
Can I create a folder without adding a file to it?
No. GitHub does not store empty folders because Git itself does not track them. Every folder must contain at least one file. Use a .gitkeep placeholder file if you need the folder to exist before you have real content for it.
What is the difference between creating a folder on GitHub and on my computer?
On your computer, you can create empty folders. On GitHub, folders are created automatically only when you add a file inside them. If you create folders locally on your computer and push them to GitHub without files inside, those empty folders will not appear in the repository.
Can I rename a folder after I create it?
GitHub does not have a rename button for folders. To rename a folder, you must move the files inside it to a new folder path using the upload or command-line method, then delete the old folder by removing all files from it.
Do I have to use .gitkeep or can I use a different placeholder filename?
.gitkeep is a convention that developers recognize, but technically any filename works. Some people use .gitignore or README.md instead. Use .gitkeep if the folder is truly empty and you just need to hold the space.
What if I create a folder path but make a typo in the name?
Delete the file with the wrong folder name, then create a new file with the correct path. GitHub will create the correctly-named folder. The old folder will disappear once it has no files in it.