Push Code to GitHub using Git Bash – Step by Step Guide

Learn how to easily push your code to GitHub using Git Bash. Step-by-step guide to initialize, add, commit and push code to remote repository.

The following are the basic Git commands that can be used to push code to GitHub using Git Bash:

  1. git init: Initializes a new Git repository in the current directory.
  2. git add .: Adds all new and modified files in the current directory to the staging area.
  3. git commit -m “commit message”: Commits the changes in the staging area with a specified commit message.
  4. git remote add origin https://github.com/username/repository.git: Adds the remote repository on GitHub as the origin.
  5. git push -u origin master: Pushes the committed changes to the master branch of the remote repository on GitHub.

Here is an example of how these commands can be used together:

$ git init
$ git add .
$ git commit -m "Initial commit"
$ git remote add origin https://github.com/username/repository.git
$ git push -u origin master

You’ll be prompted for your GitHub username and password before the push.


  • Make sure you are inside the local repository you want to push to GitHub, before executing these commands.
  • You also have to create a repository on GitHub with the same name of your local repository
  • Before pushing make sure your local repository is up-to-date with the remote repository.

Up ↑

%d bloggers like this: