Uploading Files to GitHub from Git Bash on Windows

Git Bash is a command-line interface that allows you to manage your Git repositories on Windows. One of the most important aspects of Git is the ability to upload and share your code with others on platforms like GitHub. In this blog post, we will provide a step-by-step guide on how to upload files to GitHub from Git Bash on Windows. By following these instructions, you will be able to share your code with the world and collaborate with others using Git Bash and GitHub.

Step 1: Create a New Repository on GitHub

The first step is to create a new repository on GitHub. Log in to your GitHub account and click on the “+” icon in the top right corner of the page. Select “New repository” and give your repository a name and description. Choose whether your repository should be public or private, then click the “Create repository” button at the bottom of the page.

Step 2: Clone the Repository

Once the repository is created, copy the HTTPS URL of the repository. Open Git Bash and navigate to the directory where you want to clone the repository. Type the following command:

git clone <repository-HTTPS-URL>

Replace “<repository-HTTPS-URL>” with the HTTPS URL of your repository. This will create a local copy of your repository on your computer.

Step 3: Add Files to the Repository

Navigate to the directory where you cloned the repository using the “cd” command. Copy the files you want to upload to your repository into this directory. In Git Bash, type the following command to add the files to the repository:

git add .

Here, the “.” represents all the files in the current directory. You can also add specific files by specifying their names instead of using the “.”.

Step 4: Commit the Files

Commit the files using the following command:

git commit -m "Initial commit"

Here, “Initial commit” is the message that describes the commit. You can replace this with any message that describes the changes you made to the files.

Step 5: Push the Changes to the Remote Repository

Push the changes to the remote repository using the following command:

git push origin master

This will push the changes to the “master” branch of the remote repository. If you are working on a different branch, replace “master” with the name of your branch.

Step 6: Verify the Changes

Go to your GitHub repository page and refresh the page. You should see the files you uploaded in the repository.

Conclusion:

Uploading files to GitHub from Git Bash on Windows is a simple process that can be completed in just a few steps. By following the step-by-step guide outlined in this blog post, you will be able to share your code with others on GitHub. With this knowledge, you can collaborate with others and contribute to open-source projects using Git Bash and GitHub.

Leave a Comment

Your email address will not be published. Required fields are marked *