Github sign in page

How To Push From Local Repository To Remote GitHub

what is Github

Welcome to the tutorial that will show you how to push changes from your local repository to remote GitHub repository. Before we move into the technicality of pushing, let’s talk a bit about the service called Github.

GitHub is a cloud based version control system that is used to store and manage codes or documents, and also track the changes of such documents. It has become the defacto source code management tool for most developers.

A Source Code Management (SCM) tool is used to manage and track changes that have been made to a source code repositories. Source Code is a file or set of files and folders that are written (in plain text converted into machine text using a compiler) and grouped by a programmer to execute as a software function. SCM is capable of keeping histories of changes made. It can also help to flag and resolve conflicts in the changes of source code if there is any. You can also call SCM the Version Control System (VCS).

There are many SCM service out there, some of the most popular are GitLab, Azure Repos, BitBucket, AWS CodeCommit, and GitHub.

One of the challenges of most new users is how to seamlessly push their changes from local repository to remote GitHub repository account. Here in this tutorial, I show you how to create an Organization, a remote repository, create a local repository, and push from your local repository to remote GitHub repository.


So, we know what GitHub is , let’s talk about some common terms used in GitHub.

ORGANIZATION – They are shared accounts where businesses and open-source projects can collaborate across many projects at once, with sophisticated security and administrative features. In the Organization is where you can specify roles for each member of your Team. I recommend this documentation by GitHub for more info.

REPOSITORY – The repository is where you store all your project source codes. The repository keeps the revision history of your files. You can collaborate with other people in your repository and as well monitor access to repository. Read more here

BRANCH – A branch in GitHub repository is a contained area of a repository that allows a user to experiment with fixes or features in a project. Let’s say you have a new idea for your project and would not want to alter the existing source code, GitHub allows you to branch out the code and experiment your changes. You can then merge the branch back into the branch containing the working code. You can have multiple branches in GitHub.

TEAM – These are group of people that can collaborate across many project in a GitHub organization. Read more about GitHub Team here

PERSONAL ACCESS TOKEN – A P.A.T is an authentication credential used in place of a password especially when you are authenticating GitHub account in an interactive command line interface. We will use a P.A.T to authenticate our local repository with remote GitHub repository later in this walkthrough.


You can easily create an account at

After signing up, let’s create an Organization for our project on Github. At the far right of the page, find and click the + button beside the profile picture. Select the New Organization option. On the next window, you will select the FREE organization. However, if your used case is so large, you may want to go for a premium GitHub organization.

After selecting the Free option, supply the Organization name, contact email address, and verify the captcha. Also remember to check the box for accepting the Terms and Conditions.

Also, let’s create the Repository for our source code inside the GitHub Organization.

Click on the Organization you created earlier, under Repositories, Click New Repository.

Create new remote repository

Give a name to the repository. Make sure the name is unique and identify your project. You can make the repository Public ( which means every one on the internet can access it) or Private (which means only member of your organization can access it).

give your repository a name

Click the Create Repository button to create the repository.

Create repo
Initialize and Commit Local Changes

Suppose we have our code in our machine, we need to initialize it to our local repository. Initializing our repository will enable us to connect our git client to our remote github. Navigate into the directory containing your source code and execute the command below. You can also clone the code from this link.

git init
git status

The status will show you the files and directories that needed to be committed.

Initialize the local repository and check the status

Now, use the git add to include all the contents to be committed.

git add .
git status
#where . indicates all. You can specify what to be added by using the name of the file

You should see all the content in the directory has changed to green, indicating they are sage to commit.

Add the elements to be staged in the local repository

Now to ensure we the push to the right remote account, let’s connect local repository with remote GitHub repository to our. We do this by adding the https link of the repository to our local repository.

git remote add origin

We can check the remote repository is successfully added using the remote command

git remote -v
Add your remote Github repository to you local repository

After confirming that our remote GitHub repository has been added, we can use the commit command to stage our changes.

git commit -m “first commit”

Where the -m flag indicate the commit message of the changes. It is a good practise to include a comprehensive commit message. It helps other developer working on the project understand what is done.

Since this is the first commit of this repository, it is not out of place for the remote repository to ask for authentication of the Github account. So, if you find the “Please tell me who you are” response like below do not panic. Use the config command to add your user GitHub username and email to the local repository.

git config "your Username"
git config "[email protected]"

You can rerun the commit command to stage the changes. However, this has not push our local repository changes in the remote Github repository. It only staged it for that.

Commit and add user and email of the local changes for the remote Github repository

So, we will push our local repository changes from to the remote GitHub repository with the push command. Here, GitHub will ask us to supply our account username and password for authentication.

Note that will not allow you use the same password for your account in the interactive terminal. You will need a Personal Access Token (P.A.T) for this type of authentication. Use the P.A.T where it requested for password.

Generating a P.A.T is easy. Navigate to your Github account profile at the far left of your Github console.
Click on the Setting > Developer Setting > Personal Access Token. You can generate the classic token. Select the Write and Read access for your token.

git push --set-upstream origin master
Push from local repository to remote GitHub repository.

Navigate to the console to find the changes you push from local repository to remote Github repository

Create another branch from your local repository

The good thing about version control system is you can create multiple branches to track and commit every changes you make. Doing so from the Github graphical interface can be a lot stress, on a contrary, it takes only a few commands to create a branch and push from your local repository to remote GitHub repository. So, let’s create another branch call gitFix

git checkout -b gitFix

The -b in the command above will tell git that we want to create a new branch, and switch (checkout) to that branch.

Now we are in the new branch. Let’s push this new branch from our local repository to our remote Github repository.

git push -u origin gitFix

When you check the list of branches in your remote GitHub repository, you should find the gitFix branch there.

To switch (checkout) back to the master branch use the checkout without the -b flag

git checkout master

Use the branch command to find the list of branches in your local repository. The work branch will be colored in green.

git branch

Add the –delete flat to delete a particular branch. Make sure to checkout to another branch before deleting a branch.

git branch --delete gitFix

You can repeat the commits over and over for every change you make to your application. You would not need to create another repository except you want to run another project.

Also checkout how to create and commit changes to AWS CodeCommit repository within 5 minutes.

  1. ERROR: fatal: empty ident name (for [email protected]) not allowed
    SOLUTION: delete the .git directory, reinitialize the local repository. Then readd the remote origin. Take caution to add the before adding the in that order.
  2. ERROR: Permission denied for a user that was added in the git workflow.
    SOLUTION: Add sudo in the command to be executed.






Leave a Reply

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