345

I want to add a new folder to my newly created GitHub repository without installing the Git setup for (Mac, Linux, or 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?

3

4 Answers 4

754

After extensive research, I have determined that it is indeed possible to create a new folder from the web interface. However, it requires that at least one file be included within the folder at the time of its creation.

When creating new files via the web interface, you can specify the folder path within the file name to place the file in the desired directory.

For instance, to create the file filename.md within a series of sub-folders, you can follow this approach (as illustrated on the GitHub blog):

Enter image description here

9
  • 26
    The requirement of having at least one file in the folder is actually a shortcoming of Git itself Commented Sep 1, 2014 at 12:10
  • 54
    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
    Commented 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
    Commented 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. Commented 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. Commented Mar 18, 2017 at 12:29
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.

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 Commented Jan 20, 2015 at 15:25
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.

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.