how to add folders to github

How to Add Folders to GitHub

By Mark Clark
AD

Streamlining your workflow with GitHub often involves organizing your projects into folders. This not only maintains a clean repository but also enhances the understandability of your codebase. If you're wondering how to add folders to GitHub, you've come to the right place. In this guide, we'll walk you through the process of creating folders both locally and directly within the GitHub interface.

Before we delve into the step-by-step process, let's briefly discuss why organizing your GitHub repository is crucial. A well-structured repository aids collaboration, enhances readability, and simplifies navigation.

Local Folder Creation and Push

The local working environment is where most of the coding happens. Let's first understand how to add folders to your GitHub repository from your local machine.

AD
How to Add a New Folder to an Existing GitHub Repository
How to Add a New Folder to an Existing GitHub Repository
.gitignore Explained (Day 10 Git Guide)
.gitignore Explained (Day 10 Git Guide)
How to Download Files and Folders From GitHub
How to Download Files and Folders From GitHub

Before starting, ensure you have Git and GitHub Desktop installed on your system. If you haven't, install the software, and initialize a new Git repository in your project's root folder.

Using Command Line

For those who prefer the command line, here's how to add folders:

How to Add a New Folder to an Existing GitHub Repository
How to Add a New Folder to an Existing GitHub Repository
How to Recursively Add Files and Folders in Git
How to Recursively Add Files and Folders in Git

Use the mkdir command followed by the folder name to create a new folder. For example, mkdir myNewFolder.

After creating the folder, navigate into it with the cd command. Here's how it looks: cd myNewFolder.

AD

Once inside the folder, you can start adding your files. After you're done, use the git add . command to stage all files and folders in the current directory. Then, git commit -m "Your commit message here" to commit your changes.

Using GitHub Desktop

For those who prefer a graphical user interface, GitHub Desktop is an excellent tool.

First, open GitHub Desktop and locate your repository. Right-click anywhere within the file list, and select 'New Folder'. Name the folder as per your preference.

AD

After creating the folder, you can start adding your files. Once you've made changes, click on 'Stage Changes' in the top-right corner. This will stage all the files in the current directory. Then, provide a commit message and click 'Commit'.

Creating Folders Directly on GitHub

GitHub also allows you to create folders directly within the GitHub interface. This is especially useful when you want to structure your repository on the web interface itself.

First, navigate to your repository on the GitHub website. Click on the 'Source' tab to view your repository's files.

AD

Creating Folders in GitHub Interface

In the 'Source' tab, click on the 'Create new file' button. In the filename field, type the name of your new folder followed by a forward slash (e.g., 'new_folder/' ).

After creating the folder, you can start adding your files. To do so, follow the same process. This time, when you click on the 'Create new file' button, it will open the new folder where you can create and edit your files.

Once you're done, provide a commit message in the 'Commit changes' box and click 'Commit new file'.

And there you have it! You've successfully learned how to add folders to GitHub, both locally and directly within the GitHub interface. Consistent folder organization will not only keep your repository clean but also enhance your workflow. Happy coding!

AD