Site icon JD Bots

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

Photo by RealToughCandy.com on Pexels.com

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.

Note:


Exit mobile version