Solved "No such remote origin" Git Error Fatal
Short article on how do I fix remote origin already exists git error faced when trying to push to remote origin in Github and BitBucket.
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:
- You haven't told Git to start tracking any file, or
- You have not set up the remote origin in your local repsitory.
To check if you have setup an remote origin type
git remote -vcommand in your terminal.
The solution to this "no such remote origin" Git error is very simple, just follow the steps given below.
Step 1: Intialize 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 specify file to be push 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 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 push 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 from.
Conclusion: If you follow the above steps properly then you can avoid the "no such remote origin" error in Git.
Related Topics:
Related Posts
Fix 'failed to push some refs to' Git Errors
If you have encountered the "error: failed to push refs to" error in git, then follow this solution provided in this article to easily fix the error.
[Fixed] GitHub "fatal: remote origin already exists" error
Find out to fix "fatal: remote origin already exits" github error while working with remote git repository.
How to remove node_modules from github or bitbucket
Step by step process to remove node_modules from github or bitbucket after the folder is added to the repository with the help of gitignore file.
Fix - "fatal:refusing to merge unrelated histories" git error
This article is about how to resolve or fix fatal:refusing to merge unrelated histories git error.
