The simplest way to add a folder to GitHub
You cannot create an empty folder in GitHub directly — Git tracks files, not folders. To add a folder, you create a file inside it first. The fastest method is to use GitHub's web interface: go to your repository, click the "Add file" button, select "Create new file", type the folder name followed by a forward slash and a filename (like my-folder/README.md), then commit. GitHub automatically creates the folder when you save the file.
If you are working on your computer instead, you create the folder normally, add a file to it, then push everything to GitHub using Git commands. Either way, the folder appears in your repository once at least one file lives inside it.
Key Takeaways
- GitHub creates folders automatically when you save a file with a path that includes a folder name, like folder-name/file.txt.
- You can add a folder through GitHub's website without touching your computer, using the "Add file" button and typing the folder path.
- On your computer, create the folder, add files to it, then use git add, git commit, and git push to send it to GitHub.
- An empty folder will not appear in GitHub — you must include at least one file inside it for the folder to show up.
Adding a folder through GitHub's website
Open your repository on GitHub.com and click the "Add file" button near the top right. Choose "Create new file" from the dropdown menu. In the filename field at the top, type the folder name, then a forward slash, then the filename — for example, docs/getting-started.md. GitHub reads the forward slash as a folder boundary and creates the docs folder automatically.
Type or paste the file content into the editor below. Scroll down to the "Commit new file" section, add a short message describing what you are adding (like "Add docs folder with getting started guide"), then click "Commit new file". The folder now appears in your repository with the file inside it.
You can repeat this process to add more files to the same folder. Type the same folder name followed by a new filename, and GitHub places the file in the existing folder.
Adding a folder from your computer using Git
Create the folder on your computer in the same location as your repository. You can do this by right-clicking in the folder where your repository lives and selecting "New Folder", or by opening your terminal and typing mkdir folder-name. Add files to the folder using your text editor or by copying existing files into it.
Open your terminal or command prompt in the repository directory. Type git add folder-name/ to tell Git to track everything in that folder. Then type git commit -m "Add folder-name folder" to create a commit with a message. Finally, type git push to send the folder and its files to GitHub. The folder now appears in your repository online.
Why you need a file inside the folder
Git is a system for tracking changes to files, not for tracking empty folders. If you create a folder on your computer and push it to GitHub without any files inside, Git ignores it completely — the folder will not appear in your repository. This is why the common workaround is to create a file called .gitkeep inside an empty folder you want to preserve.
To add a .gitkeep file, use the web method above and type folder-name/.gitkeep as the filename. Leave the file content blank and commit. The folder now exists in GitHub even though it contains only a placeholder file. Later, when you add real files to the folder, you can delete .gitkeep if you want.
Organizing multiple levels of folders
You can create nested folders — folders inside folders — by using multiple forward slashes in the filename. For example, typing src/components/buttons/button.js creates three folders: src, then components inside it, then buttons inside that, with button.js as the file at the end. GitHub creates the entire structure in one action.
This works the same way on your computer. Create the folder structure manually or use the terminal command mkdir -p src/components/buttons, add files to the innermost folder, then run git add, git commit, and git push. The full folder structure appears in your GitHub repository exactly as you organized it.
What to do if a folder does not appear after pushing
If you pushed a folder to GitHub and it still does not show up, the folder is probably empty. Check your repository on GitHub — if the folder is missing, it means no files were actually added to it. Go back to your computer, add at least one file to the folder, then run git add, git commit, and git push again.
Another reason a folder might not appear is if you accidentally added it to your .gitignore file. Open .gitignore in your repository and check whether the folder name is listed there. If it is, remove that line, save the file, and push again. Your folder should now be visible.
Frequently Asked Questions
Can I rename a folder after I add it to GitHub?
Yes. On GitHub's website, you can delete the files in the old folder and recreate them in a new folder with the new name. On your computer, rename the folder, then run git add, git commit, and git push. Git tracks the change and updates your repository.
What is the difference between adding a folder on GitHub's website versus on my computer?
The website method is faster for small changes and requires no software installation. The computer method is better if you are working with many files or folders at once, because you can organize everything locally first, then push it all in one commit. Both end with the same result in your repository.
Do I need to create a folder before adding files to it?
No. You can type the folder path directly in the filename field (like folder-name/file.txt) and GitHub creates the folder automatically. You never need to create the folder separately.
Can I add a folder with no files in it?
Not directly. Git ignores empty folders. To preserve an empty folder, add a .gitkeep file inside it. This is a placeholder file with no content that tells Git to track the folder.
What happens if I type a folder path with a typo?
GitHub creates the folder with the typo in its name. You can fix this by creating the files again in a new folder with the correct name, then deleting the files from the misspelled folder. The misspelled folder disappears once it is empty.