Add a folder

How do we add a folder to a repository?   I have searched and searched and I see an icon for a new file, but nothing anywhere for a new folder.  Nor did I find the question asked anywhere here on the forum, which I find quite weird.

7 Likes

Hello @mbrasseau,

To create a new folder in a repository click “create a new file.” Type your new folder’s name in the area where you would write the file name, and at the end of the file name type a “/” to initilize it as a folder. After this you can create a new file in the folder.

Alternatively, you can clone the repo locally and add a new folder, and then push the changes to github using the command line or Github Desktop.

10 Likes

Thank you so very much!

1 Like

Hello, thanks for the solution! What if I want to create a new folder then upload files from the desktop?

Hello @mukulmc03, welcome to the GitHub Support Community!

You can also create new folders by simply dragging and dropping a folder with files to your repository on GitHub and then uploading them. If you want the folder you’re uploading to be inside a specific sub-folder, be sure to click on and enter that sub-folder before uploading your files.

The suggestion to name a directory as directory/ no longer appears to work. The create File menu item insists on a file being added to the directory. The question remains, how to create an empty directory in a GitHub repository.

You can’t, that’s part of how git works. Git does not track directories other than as parent directories of tracked files.

If you want a directory to exist on checkout, you can create an empty file in that directory (common filenames for that purpose would be .keep or .gitkeep). However, in many cases it’ll be better to let the build process for your project create the directory if necessary.

Thank you, it helped me to get started with Github in the way I wanted to.

1 Like