How to push large folders to GitHub, using Git Bash, all at once.

Whether it is code, images, program files, or even basic word and text files, pushing folders with few files to GitHub probably isn’t an issue for most basic to newbie developers or GitHub users. Even if you don’t want to go through the hassle of navigating via the command line to push files, GitHub allows you to easily drag and drop files from your open windows directly unto your repository open on your web browser, but sadly, we can’t say the same for folders with hundreds of files.

Quite unfortunately, when you try to drag and drop a folder containing a large number of files, you get the following prompt:

You could consider adding each file individually, but that could take forever, depending on how many files the folder contains. This can be frustrating, especially when it’s crucial to have the said folder in your repository, and you don’t know any other way to go about it. There is a fix to this, however, using a GUI like Git Bash.

Git Bash is an application that provides a Bash command-line environment for Git. It was produced specifically for the Windows operating system. Just like a regular Linux-based system, it utilizes the same navigation commands including:

ls – to list all the files in the directory

cd – to change directory to a specified one

cd .. – to go back to the previous directory

If you don’t have Git Bash already installed on your system, you can download it here for 32-bit users and here for 64-bit users. After downloading, just simply click install and follow the prompts to complete installation.

Before getting into setting up the environment for pushing the files, I’ll briefly explain what push and pull commands actually mean in Git. A push command is a Git command that is used to upload files or changes to files from your local repository on your local machine to your remote repository on GitHub, while a pull command is actually a type of request that is made when you are ready to inform other collaborators about the changes that have been pushed to a branch, for them to discuss and analyze it for approval to be pushed to the main branch.

Now, to access Git Bash from anywhere (e.g. a folder you want to push to GitHub) on your machine, you can follow the steps below:

1. Right-click within the folder and click on Git Bash here:

2. This will open that folder in Git Bash as displayed below:

3. To view the files in the folder, type the ls command and press enter. This lists all the files and subfolders within the folder from which you entered Git Bash:

4. To enable you to copy and paste within Git Bash using the ctrl+c and ctrl+v commands, change the preferences by right-clicking on the window and clicking Options as shown below:

5. Click on Keys. Then check the box that says Ctrl+Shift+letter shortcuts and click Save to apply:

The next steps show how to clone the remote repository to your local directory, add the folder to be pushed, and push it:

1. Go to your repository on GitHub and copy the URL to clone your repository, preferably HTTPS, as follows:

2. Go back to Git Bash and type git clone “URL”, where “URL” is the HTTPS URL you just copied from GitHub and hit enter:

3. When your repository has been cloned, you should see the same prompts as in the image above. After this, go back to your folder window and copy the folder you want to push into your cloned repository within your files explorer window. As opposed to before cloning on Git Bash, your cloned repository should now be present as a folder like in the image below:

4. Come back to Git Bash and type ls to list the files and show your cloned repository, type cd “repository_name” to navigate into the repository, and then type git add “folder_name” command, where folder_name is the name of the folder you want to push (which you have already copied into your repository folder):

5. Type git commit –m "commit_message", where commit_message is the title for the commit:

6. Type git push to push the folder to GitHub:

7. To confirm that your folder has been pushed, go back to your repository on GitHub in your browser, refresh the browser window, and check for the folder you just pushed, it should be present there:

Now you have successfully pushed your large folder with a lot of files to your GitHub repository.

There are other methods of pushing large folders to GitHub apart from using Git Bash which may be preferable to you in terms of usability, interface, level of technicality, etc. But overall, I would recommend using Git Bash any day, considering it is lightweight and easy to use. The fact that it is optimized for Git is also another reason why it is the obvious choice of application for this operation.

You can further explore other features that Git Bash offers, whether they are related to pushing and pulling files, or other command-line operations. Until then, keep coding💻✌😎!