In GitHub, I already have an Automata repository with 1 project in it. I just want to add more projects in this repository. I wish to create different folders inside the Automata repository so I can better organize my projects. In other words, my question is "how to add a folder inside a repository?"
2 Answers
An empty directory cannot be part of the git versioning system. But you can use a little workaround.
You can add a .gitignore
inside your empty directory. Add these lines:
#Ignore everything
*
#dont ignore this file
!.gitignore
The *
will assure that no files in this directory will be tracked. However, as you probably want to add files later, you shouldn't put the star in. Therefore your .gitignore
can be empty. You can add real files to ignore later, as your project grows.
To create the .gitignore
type the following in your console:
$ mkdir $foldername
$ touch .gitignore
$ git add foldername/.gitignore
$ git commit -m 'added placeholder folder' $foldername
where you replace $foldername
with the desired name of your folder.
Now you have a folder which is not completely empty, but only has one hidden file.

- 47
- 1
- 4
Github doesn't allow empty folders. You can make a folder and add a placeholder file to it and push that to your repository. That's the only way you would be able to create a new folder in your GitHub repo. You can't create a folder and then add files to it on GitHub, but rather the creation of folder must happen with a file inside that folder.
You can either push the folder through git commands. There's another option to directly drag and drop folders from your system to your GitHub repository.
To directly add a folder from the GitHub website, click on Create New File. Type in name of folder you want to create, add the file and Commit new file to add it. You can refer the below gif -

- 5,583
- 3
- 15
- 32