Creating folders inside a GitHub repository without using Git
Asked Answered
A

4

342

I want to add a new folder to my newly created GitHub repository without installing the Git setup for (Mac, Linux, and Windows). Is it possible to do so?

I can't have Git all the time with me when I work on different systems/machines. I know how to add files directly in a repository on github.com/[USER]/[REPO]. Can we create a folder as well?

Antagonism answered 12/9, 2013 at 20:16 Comment(2)
You would probably find codenvy or Cloud 9 compelling.Animadvert
Possible duplicate of How to create folder in github repository?Chloric
A
748

After searching a lot I find out that it is possible to create a new folder from the web interface, but it would require you to have at least one file within the folder when creating it.

When using the normal way of creating new files through the web interface, you can type in the folder into the file name to create the file within that new directory.

For example, if I would like to create the file filename.md in a series of sub-folders, I can do this (taken from the GitHub blog):

Enter image description here

Antagonism answered 13/9, 2013 at 16:54 Comment(9)
The requirement of having at least one file in the folder is actually a shortcoming of Git itselfBergman
It would be great if they made this more intuitive, like adding a "create folder" button to the web interface, while editing a file if not at the root. What they did is cool, but probably confusing to new/nontechnical users.Marciemarcile
Rawr, yes, this is very not intuitive for first-timers. I like how they do it, but seriously, why could I not find it in their docs?Roselani
It probably has something to do with the fact that in under Linux/UNIX, there is no difference between folders and files. A folder, or directory, is just a file with the names of other files in it. tldp.org/LDP/intro-linux/html/sect_03_01.html I know it doesn't make sense to Windows folk, but it's true.Signorina
This is nice, but it only works for text: for, say, a PDF, the equivalent "Upload file" button does not allow the path to be changed.Broadtail
@EOL True, but you could use this technique to create a random text file, then browse to the new folder, upload a file, then remove the text file. It's messy, but it does work if you need it.Koy
@Marciemarcile GitLab did itDisquisition
I'd say using a .gitkeep file here would be appropriate if you don't want to make a file with any contents.Kwangtung
This doesn't seem to work any more. The UI is different, and slashes get translated into dashes when you save.Pineda
M
115

When creating a file, use slashes to specify the directory. For example:

Name the file:

repositoryname/newfoldername/filename

GitHub will automatically create a folder with the name newfoldername.

Mooncalf answered 22/1, 2014 at 21:14 Comment(1)
Hmm. I dont tend to create files using the github web app. Rather, I tend to use git add running in my local shell. How would I work your advice into my git command sequence running on my localhost? Typically I run this sequence in a bash shell on my localhost: git init, git add file1.abc, git add file2.abc, git commit, git remote add origin somegithuburl, git push -u origin master THank youFox
A
22

You can also just enter the website and:

  1. Choose a repository you have write access to (example URL)
  2. Click "Upload files"
  3. Drag and drop a folder with files into the "Drag files here to add them to your repository" area.

The same limitation applies here: the folder must contain at least one file inside it.

Apotheosize answered 9/11, 2017 at 23:40 Comment(0)
E
3

Another thing you can do is just drag a folder from your computer into the GitHub repository page. This folder does have to have at least 1 item in it, though.

Elevate answered 7/12, 2019 at 14:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.