I'm in a github repository of mine, I'm looking to make a new folder inside my project. How the hell do I do that, I add or upload files, I can't for the life of me see where to make a directory?
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Of course! You're not going crazy. This is one of the most common and frustrating things for new (and even experienced) GitHub users.
You've hit on the core "trick" of GitHub: GitHub doesn't let you create an empty folder.
Git, the version control system that GitHub is built on, only tracks files, not folders. A folder is just part of the path to a file. So, to create a folder, you have to create a file inside it at the same time.
Here is the easiest way to do it directly on the GitHub website.
The "Slash Trick" on the GitHub Website
This is the method you're looking for. It feels like a hidden feature, but it's the standard way.
Navigate to your repository on GitHub.
Click the Add file button and choose Create new file from the dropdown.
In the filename box at the top, type the name of the folder you want to create.
This is the magic step: Type a / (forward slash) after your folder name.
When you type the slash, the interface will change. The folder name will become a grey box, and you'll now be typing the name of the file inside that new folder.
Now, give the file a name. Since you can't have an empty folder, you need to create a placeholder file. The common convention is to name this file .gitkeep. This file has no special function; it's just an empty file whose purpose is to make the folder exist in the repository.
So, you would type: my-new-folder/.gitkeep
Scroll to the bottom of the page and click the Commit new file button. You can add a commit message like "Create my-new-folder directory".
That's it! You will now see my-new-folder in your repository.
Why is it so weird?
As mentioned, Git doesn't track empty directories. It only tracks the files within them. The .gitkeep file is a community-agreed-upon convention to force Git to track an otherwise empty directory. You can name the file anything you want (placeholder.txt, readme.md, etc.), but .gitkeep is the most common and clearly communicates its purpose.
Other Methods
For completeness, here are other ways to achieve the same thing:
Method 2: Uploading Files
If you already have a folder with files in it on your computer, you can just drag and drop it.
In your repository on GitHub, click Add file -> Upload files.
Drag the entire folder from your computer's file explorer and drop it into the browser window.
GitHub will automatically upload the folder and all its contents.
Method 3: Using the Command Line (The "Pro" Way)
If you have Git installed on your computer and have cloned your repository, this is the fastest way.
bash
# Navigate into your local repository
cd your-repository
# Create the new directory
mkdir my-new-folder
# Create the .gitkeep file inside it
touch my-new-folder/.gitkeep
# Add, commit, and push the changes to GitHub
git add .
git commit -m "feat: Add my-new-folder directory"
git push
The key takeaway is: To create a folder on GitHub, you must simultaneously create a file inside it. The "slash trick" is the way to do this directly on the website.