How to: Pushing to GitHub Repository

Eugene Yeboah

Written by:

Eugene Yeboah • October 6, 2021

How to: Pushing to GitHub Repository

The command to push to to a GitHub repository is as follows: git push -u origin main With that said, there are a few steps that need to be taken before pushing to GitHub:

1) You must set your origin

Setting you origin is what points your local repository to it's remote counterpart. Setting the origin is essentially setting up the destination, you are defining the 'origin' (where the remote / central repository). A push command without setting an origin will fail as git will not know where to push to. The command to set the origin is below:

2) You must 'Add' and 'Commit' your changes

As mentioned earlier, git follows a life cycle, pushing is the last step. A quick summary of the git version control cycle is as follows:

  1. You update your code (maybe in a code editor like Visual Studio Code)
  2. You add those changes to your staging area using the 'git add' command,
  3. You your staging area using the git commit -m'your comments here' command.

Before you can push to the remote repository, you will have to first 'add' all your changes to your staging area. After adding your changes, you must commit your changes. After committing your changes you may now run the git push command.

The Skinny

git remote add origin https://github.com/EugeneYeb/seamlesscollab.git git branch -M main git push -u origin main