Clone Repository & Push Changes using Git Bash

Posted by

There are two methods I use to push code to GitHub.  Method 1. Visual Studio Code.  Method 2. Git Bash.  Both are effective and I know people who use one over the other all the time.  In this article I will walk through cloning your repo in GitHub locally via SSH, clone the repo, and then push changes to your GitHub repo via Git Bash.

If you are looking for my blog article on how to do the above via Visual Studio Code, please go to this URL:
https://digitalthoughtdisruption.com/2020/09/09/clone-repository-push-changes-using-visual-studio-code/

If you are looking for an article on how to create the GitHub repository please see the following link:
https://digitalthoughtdisruption.com/2020/09/09/create-a-repository-in-github/

Step by Step Process:

Clone GitHub Repository Locally and Push Changes via Git Bash

We are going to want to make sure we have Clone with SSH select

Copy to clipboard

$ git clone <contents of clipboard>

This command will pull down a copy of the repo living on GitHub

$ ls

This will show that the repo has been successfully cloned locally

With a simple search in explorer and a la -la command you can see all the files that are in the repo

For the sake of demonstration I created three quick empty files so I have something stored locally

$ git status

This command showed that there have been some changes made that are current not being tracked

$ git add .

This command will add all files in this directory

$ git status

This will now reflect we have added the files to be tracked and are awaiting a commit

$ git commit -m “message”

This command now commits the new files but GitHub is still unaware of this commit, so now we need to push the files up to the central repo

$ git push origin master

This will now push the changes up to the GitHub Repo

If we go back to the GitHub page & refresh you should see the new files and their comment on the main repo page

You can also see that a new commit has been applied

Summary:
It is not difficult to use the Bash in order to push and pull down files.  In my next article I will show how to perform these same methods but within VS Code.  As always, I hope y’all found this useful.

One comment

Leave a Reply