Skip to main content

Explore your training options in 10 minutes

Create Folder in GitHub: A Guide

James Gallagher - September 30, 2020

There is no Git feature that supports the creation of an empty folder. To create a folder in Git, you must commit a folder to a repository that contains at least one file, even if that file is hidden.

In this guide, we’re going to discuss how to create a folder on GitHub. We’ll walk through an example of how to create a folder from the Git command line, and give instructions on how to create a folder from the GitHub web interface.

Create a Folder in GitHub: From Git

We’re going to start work on an update for a project called ck-git. We already have a Git repository set up for this project. Before we start working on our updated code, we’re going to create the directory structure for our code.

Get offers and scholarships from top coding schools illustration

Find Your Bootcamp Match

  • Career Karma matches you with top tech bootcamps
  • Access exclusive scholarships and prep courses

By continuing you agree to our Terms of Service and Privacy Policy , and you consent to receive offers and opportunities from Career Karma by telephone, text message, and email.

Our GitHub repository currently contains no folders:

We want to create a folder called docs and a folder called dev . To do this, we’re going to use the mkdir command:

mkdir docs dev

This command creates our two directories. If we add these folders to a commit and push our changes, they will not show up on GitHub. This is because GitHub does not display empty folders.

To create our new folders, we need to add contents to our folders. Because we are only initializing our project, we can add in a few blank single files.

These blank files will let us create our folder without having to actually start work on our updates before we have created the directory structure and uploaded it to Git.

Let’s create two blank files to populate our new folders:

touch docs/.gitkeep
touch dev/.gitkeep

We have created two files called .gitkeep . Our two new directories now contain one file each. The .gitkeep file name is often used to create blank folders. However, there is no requirement that the name of your file needs to be .gitkeep to create a folder.

Now that these files exist, we can track our otherwise empty folders and commit our code:

git add *
git commit -m "feat: Create directory structure"
git push

The git add command adds our files to the staging area. The git commit command creates a commit with our changes. The git push command pushes our changes to our remote repository. Our remote is hosted on GitHub.

Venus, a software engineer at Rockbot

"Career Karma entered my life when I needed it most and quickly helped me match with a bootcamp. Two months after graduating, I found my dream job that aligned with my values and goals in life!"

Venus, Software Engineer at Rockbot

Let’s see what happens when we run these commands:

[master f10ed95] feat: Create directory structure
 2 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 dev/
 create mode 100644 docs/

Our code successfully changes our files. We now have two new folders in our GitHub project: dev and docs. We can check that our folders exist by navigating to the GitHub dashboard for our project:

Each of these folders contains one file. Now that we’ve defined the directory structure, we are free to continue working on our project.

It’s not always necessary to upload empty folders before you have worked on them. If you need to for some reason, such as if you are required to show your new structure to other collaborators, these are the steps you should follow if you want to add the folders from Git.

Create a Folder in GitHub: From the Web Dashboard

There is no user interface feature to create a blank folder in GitHub. To create a new folder, you need to create a new file and specify the directory in which that file should appear.

In other words, you can only create a folder after you have created a file.

We want to add one more directory to our code called “assets”. To start, let’s navigate to our repository and click on the “New file” button.

In the top text field, we’re going to create a file called “assets/.gitkeep”:

This will let us create a folder called assets and a file called .gitkeep in that folder. Git automatically displays the new folder path when you type in a / .

Optionally, you can add text or code to the file that you have created. Again, “.gitkeep” is only a placeholder file name. You can name your file whatever you want.

Next, click Commit new file . This will add our new file to our repository. If we go back to our main folder, we can see that our new folder and file have been created:

We’ve now successfully created a folder in GitHub.


GitHub does not allow you to add blank folders to your Git repository. A folder must contain a file before you can add it to a repository. If you want to create a new folder, create it first and then add a placeholder file into that folder. Then, add the new folder and file to your Git repo.

Now you have the tools you need to create a folder in GitHub like a pro!

About us: Career Karma is a platform designed to help job seekers find, research, and connect with job training programs to advance their careers. Learn about the CK publication.

What's Next?

James Gallagher

About the author: James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse,, Afrotech, and others.

Skip to main content