Pushing code to github using cmd

GitHub Logo

Have you ever had over 10 duplicates of the same application on your local PC or USB? If you have, your folders were probably named something like, “Codeffee”, “Codeffee Updated”, “Codeffee Updated01”, “CodeffeeUpdated01 Updated”, “Codeffee Final”, “Codeffee Final Final”, I’m sure you get the picture. After not attending your project for 3 days, you begin to wonder which is which. Source Control software such as Git, SVN, TFS and others help the developers with this issue. They help you manage and track your code better. This post, however will only cover git.

You’ll need

  1. GitHub Account
  2. Git installed on your PC

Let’s get dirty

Verify Successful Installation: The first thing you wanna do is to be sure that Git was installed properly. So open your terminal or your command line and type in the following command, and if it shows you your Git version, then you’re good to go. NOTE: the dollar sign ($) means you path (e.g. C:\Users\Codeffee\Documents\…)

$ git --version

Move To The Project Directory: Copy and paste the project full path of your project to your terminal. Suppose my project name is HaveCoffee and it resides in the Geeking folder in Documents: “C:\Users\Codeffee\Documents\Geeking\HaveCoffee”.

$ cd C:\Users\Codeffee\Documents\Geeking\HaveCoffee

Prepare Your Local Repository: Once you’re at your project directory, use these commands to prepare your local repository for an online push

$ git init
$ git add .
$ git commit -m "Type your commit message here"

Global Configurations: Config your global username and email. I’d advise you to enter the email you used you to create a GitHub account.

$ git config --global "Your Name"
$ git config --global "Your Email"

Create A New Remote Repository: Head over to GitHub, sign in and on your “timeline” click on New Repository and enter your repository details and click Create Repository. You should have something similar with the screenshot below


Add Remote Repository: Copy your repository URLĀ (the highlighted url on the above image) to your clipboard. Your repo url will be different. Once you’ve copied it, head over to your terminal again and paste it using the following commands

$ git remote add origin REPO-URL
$ git remote --v


Push Code: The final step is to push your code to GitHub. After you type in the following a command, a GitHub login form might pop up, just fill in your credentials and login.

$ git push -u origin master


Verify Code on GitHub: You might wanna verify that the code was successfully uploaded to GitHub. So head over and check


If you can see something like the above screenshot, that means you were able to follow through successfully. Now you can use your USB for better things such as storing movies. On the second part of this tutorial, I’ll be covering some common errors you might encounter while using Git.

Leave a Reply

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