Search code examples
gitgithubuploadsubdirectorygit-bash

How to upload sub folders on GitHub


How to upload folders on GitHub after I have created a repository, I need to upload a folder inside my repository? How will I be able to do that using git-bash or from terminal?

I have added the folder to git by giving command like

$ git add <folder name>

Solution

  • Git does not support addition of empty folder. However you can create .gitignore or .gitkeep or any other hidden file in folder and add it.

    As per Git documentation, Currently the design of the Git index (staging area) only permits files to be listed, and nobody competent enough to make the change to allow empty directories has cared enough about this situation to remedy it. Directories are added automatically when adding files inside them. That is, directories never have to be added to the repository, and are not tracked on their own.

    Please see this for more info : https://git.wiki.kernel.org/index.php/GitFaq#Can_I_add_empty_directories.3F

    You can opt to create a .gitignore or a .gitkeep file inside the directory.

    See this for more information :How do I add an empty directory to a Git repository?