Add a folder #22534
-
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. |
Beta Was this translation helpful? Give feedback.
Replies: 22 comments 53 replies
-
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. |
Beta Was this translation helpful? Give feedback.
-
Thank you so very much! |
Beta Was this translation helpful? Give feedback.
-
Hello, thanks for the solution! What if I want to create a new folder then upload files from the desktop? |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
The suggestion to name a directory as |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
Thank you, it helped me to get started with Github in the way I wanted to. |
Beta Was this translation helpful? Give feedback.
-
On GitHub you can do it this way:
|
Beta Was this translation helpful? Give feedback.
-
I'm new to GitHub, so maybe i didn't get it yet. But to me this seems to be a crucial flaw of this platform. How can a coding platform which is so widely used not support such an essential functionality ... |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
To add a folder to a GitHub repository, you can follow these general steps: Navigate to Your Repository: Upload Files: If the folder you want to add doesn't exist locally on your machine, create it using your file explorer or command line. Open a terminal or command prompt. Navigate to the local repository's directory using the cd command. Use the following commands to add the folder and its contents, and commit the changes: bash
This stages the changes (using git add) and then commits them with a message. Push Changes to GitHub: After committing changes locally, you need to push them to the GitHub repository. bash
Replace 'branch_name' with the name of the branch you are working on (often, it's the 'main' branch). Now, your folder and its contents should be added to the GitHub repository. If you are working with a new repository or need to initialize a new repository on GitHub, you can follow GitHub's instructions when creating a new repository, including a guide on initializing with a README file and adding existing files and folders. You can find these options when creating a new repository on the GitHub website. |
Beta Was this translation helpful? Give feedback.
-
whomever at github thought that adding a "/" to a filename was an appropriate way to create a folder FLUNKED user interface design 101. That is the most asinine non-intuitive poorly thought out way to create a folder i have ever seen in 40 years of software development. it is basically stupid. thanks @SethClydesdale for writing up the answer. it is rather unfortunate that you had to do because of github's poor UI design |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
Thanks #1 |
Beta Was this translation helpful? Give feedback.
-
Thank you so much |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
not working |
Beta Was this translation helpful? Give feedback.
-
Hmm. This one confused me just a moment ago, because I was searching for "create a new directory". So I was not used to "create a new file" being used for this. Also, folder is a strange name - should we not call it directory instead? Right now this confuses me. But if everyone else is using that terminology here, well ... Still, UI-wise I would actually add a second entry, "add a new directory". Right now it is a bit confusing that this has to be done via "add a new file" - I was confused why we can only add new files but not a new directory! Of course we can via appending the /, but I still find that confusing when it is meant to create a FILE. I understand we can create a new file, and automatically create a directory, but what if I FIRST want to create the directory, and only lateron add a file? On Linux I often create a dir and only later add content, such as by writing a new file. I never ever FIRST create the file and only upon SAVING that file, expect that the directory is AUTOMATICALLY created. That seems backward logic to me and I think many Linux users here also agree with that - see how many upvotes the original threadstarter got. In a comment above it is reasoned by some that this is due to git not tracking directories. This may be, but github is more than "merely" git; it also lets people view files and directories content easily. So github already uses an UI and some kind of internal logic that is independent on git, so based on that rationale and observation I would also reason that "add new directory" should be an action too, irrespective over as to whether git itself tracks directories or not. |
Beta Was this translation helpful? Give feedback.
-
They need to make a better way to make folders. Its 2025 |
Beta Was this translation helpful? Give feedback.
-
Open your repo and create a new file, give a name to your folder, example you want 3 folders, like: The file |
Beta Was this translation helpful? Give feedback.
-
This took me an embarrassingly long time to figure out, but I created a guide on how to do it once I figured it out: https://youtu.be/IG1WeDXkAtA I hope it helps someone |
Beta Was this translation helpful? Give feedback.
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.