Solved “No such remote origin” Git Error Fatal

featured Image

Find out how to solve the git no such remote origin error while working with the Git repository.

Sometimes when we try to push our local changes to our remote repository we might come across an error : “no such remote origin” when we try to push the changes to a remote repo.

This error might occur for two reasons:

  1. You haven’t told Git to start tracking any file, or
  2. You have not set up the remote origin in your local repository.

To check if you have setup an remote origin type git remote -v command in your terminal.

The solution to this “no such remote origin” Git error is very simple, just follow the steps given below.

Step 1: Initialize Git in your working folder

To initialize git, you have to type this command in your terminal:

git init

Step 2: Add the files to track by Git

To add the files to be tracked by Git, we use the command:

git add .

The git add command adds the files or changes in your directory to the staging area.

The git add . , adds all the new files and changes to the staging area.

Or if you want to add only a specific file to be pushed to remote, type:

git add filename.md

Note: Add the file name with the extension.

Step 3: Commit our local changes

Next, we have to commit our local changes before pushing to remote using :

git commit -m "added new files"

Step 4: Set up Git remote origin

Here, we will add the remote git repository to our local repository using the command git remote add origin with the git repository URL.

git remote add origin https://github.com/USERNAME/RepoName.git

This will now let the local repository to communicate with the remote repository on Github to commit our changes or pull new changes from the remote one.

Note: To get the github repository URL, make sure you have already created a repo in Github.

Step 5: Push the changes to a remote repository

The last step would be to push all the changes from our local repo to the remote repository using the command:

git push -u origin master

This will push all the changes to the master branch.

The -u flag adds a tracking reference for every branch you have successfully pushed onto the remote repository. So next time you can just use the git pull without any arguments and Git will know from which branch to pull the remote changes.

Conclusion: If you follow the above steps properly then you can avoid the “no such remote origin” error in Git.


Related Topics:

Open Github Repository Directly In Vscode In Browser Online

How To Create New Folder In Github?

Your Git Gateway backend is not returning valid settings – Fix

How to remove node_modules from github or bitbucket

GitHub “fatal: remote origin already exists” error – Fix

Related Posts

git commands with example

Top 40 Git commands with Examples

GitHub has become an essential tool for developers to manage, store, and collaborate with other developers on software projects. With its simple powerful git-based version control system, GitHub allows users…

Read more
Check GitHub Account in the Terminal

Check GitHub Account in the Terminal

GitHub is an integral tool for developers to store, manage, and collaborate on software projects with other developers. And as we work more and more in the command line it…

Read more
featured Image

How to make list of objects in Netlify CMS using list and object Widget

Here in this Netlify CMS tutorial we will how easily we can make a list of objects using list and object widgets. This will allow us to add multiple objects…

Read more

Leave a Reply

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