How to Add Folders to GitHub

How to Add Folders to GitHub

If you’ve been wondering how to add folders to GitHub, you might be a bit frustrated. They don’t make it very intuitive, do they? I mean, I struggled to locate the secret button for a good minute before thinking, WOW, not cool, GitHub!

So, let’s just cut right to it, shall we?

What is the trick: How to add a folder in GitHub? 

You can’t just jump right in and add a folder to GitHub, without first having a repository to add that folder to. So, first things first, make sure you are not trying to upload a folder to a repo that doesn’t exist.

Once you create a repository, then you can add a folder to it.

Let’s fix that!

Navigate to the repository where you want to add a folder

To add a folder to GitHub from your computer, start off by navigating to the repository where you would like the folder to go.

Search for it by looking through the repositories page of your GitHub profile.

Hit Add file

Once you find a repo, open it up to reveal the repository’s overview page. On this screen, you’ll see a button labeled “add file” right next to the green code button. Hit this, and select upload files from the drop-down menu.

Find the folder you want to upload

In the middle of the screen, click on choose your files.

A window will pop up, letting you search your computer for the folder to upload. As you might expect, you can also drag and drop if that is more your style.

Now, commit the changes

Now comes the fun part: committing the changes and uploading the folder! Add a description for your commit if you want, and just hit Commit changes.

Did we forget about good ol’ fashioned terminal?

There isn’t much else to it. But if you want to add a folder to a git repo through your terminal or command prompt, you can do this in a few quick steps too.

You can start by navigating to your git repo using the cd command. From there, use the following commands to create and add a new directory:

$ mkdir new_dir

$ git add new_dir/

Now, you can push the changes to your remote repository on GitHub and call it a day!

Final Thoughts

Hopefully, this quick tutorial solved your burning question about how to add folders to GitHub. How did you make out? If we solved your problem or if you run into trouble, drop a comment below with your questions!