How To Upload Folder To GitHub?

1689 Views
0 rating based on 0 reviews

There are several ways to upload files to GitHub, but most of them require to fetch a file from the server where the code is hosted. Sometimes your access rights do not give you sufficient permissions for uploading files in this way. The other day I had to prepare a folder with about 100 files for GitHub repository, but could't find an easy solution for doing that.

Upload folder to GitHub

GitHub platform is an open-source project platform where people working together in a team upload their folders or files in a single project in their repositories to express their views and ideas for the rest of the people to see and people can also benefit from their works by downloading it.

You can browse and download public repositories but you can only contribute content to repositories if you have a GitHub account. GitHub repository is a Git repository, where you can upload any file or folder to it using a Git client. A folder can be uploaded in GitHub for others to see, edit and also save for future purpose in two ways.

By selecting files

Selecting folders and uploading them via the web is an easy way to upload in GitHub as it does not require the client application to be installed on your local computer. But you must have a GitHub account to upload folders designated to your account. Otherwise, the files will not upload because only registered users have the option to upload.

  1. Log in to your GitHub account.
    GitHub Sign-in
  2. Select my repository from your account option on the right section of the webpage.
    your account option
  3. Select the repository you want to upload your folders into.
    My repository list
  4. If you prefer a new repository, then click “New [green labeled]” and create a new repository.
  5. Click “Add file” on the repository page and then click “Upload new files”.
    Editing repository
  6. You will have two methods to upload the file. Click “choose your files” and browse through your directory and select the file you want to upload. You can also go to your local file storage and drag the file on the upload webpage.
    Folder upload options
  7. When you drag a lot of files, GitHub will issue a warning. Try to upload less than 100 files/folders.
    issue a warning
  8. The folder will be uploaded. Wait for the uploading to finish.
    Completion Bar
  9. You can also add a description if you wish in the “Commit changes” section. Click “Commit Changes” to finish the upload.
    Description of committing changes

You will have your folder on the repository page.

By using the desktop interface

To perform this action, you must have a GitHub client installed on your local computer. If you don’t have it, you must download it from https://desktop.github.com/. Install the file and log in to your GitHub account. Then follow the procedures stated below. 

  1. Open your Command Prompt from Windows or type “cmd” after starting the “Run” application.
    Command Prompt from Windows
  2. Change the directory to the location of the folder.
  3. Type the following Commands in your prompt.
       git init
       git add
       git commit -m "Your message about the commit"
    git remote add origin https://github.com/yourUsername/yourRepository.git
       git push -u origin master
       git push origin master
  4. Click “Enter”.
  5. Go to your desktop interface. Click “My repositories” on the menu section and select the repository where you uploaded your files.

You will see all the files you uploaded.

Summary: Upload folder to GitHub

  • Download the GitHub Desktop application and install it.
  • Open the GitHub Desktop application.
  • Sign in to your GitHub account.
  • Go to File menu and click New local repository option.
  • Enter a name for your local repo (optional) and click OK button.
  • Go to Repository tab and click Add button.
  • Click Choose… button on the opened window and select a folder that you want to add to the local repo (for example, C:/users/username/documents/gitdemo).
  • Click Open button on the window.