335

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?

2

4 Answers 4

738

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

9
  • 25
    The requirement of having at least one file in the folder is actually a shortcoming of Git itself Sep 1, 2014 at 12:10
  • 51
    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.
    – trysis
    Nov 14, 2014 at 17:23
  • 2
    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?
    – Phil Tune
    Jun 17, 2015 at 15:55
  • 2
    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. Apr 6, 2016 at 1:57
  • 4
    @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. Mar 18, 2017 at 12:29
113

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.

1
  • 3
    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 you Jan 20, 2015 at 15:25
21

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.

0
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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.