Errors Git

fatal: No such remote 'origin'

fatal: No such remote 'origin'

Most likely you are trying to run

$ git remote set-url origin https://github.com/name/project.git

Try running this first

$ git remote add origin https://github.com/name/project.git

2

To https://github.com/YourName/yourproject.git
! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'https://github.com/YourName/yourproject.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Most likely you are trying to run git push origin master in a new repository.

At the same time, when you created the remote repository on GitHub you ticked the initialize with readme file option.

So the remote repository has the file README.md while the local one does not. Git does not understand how this could have happened and assumes that someone (possibly you) added something to the remote repository that the local repository does not track.

First of all, try

$ git pull origin master

$ git push origin master

Git will download the file README.md from the remote repository, and then you can push safely

If the pull did not work, for example, you got an error

From https://github.com/andreiolegovichru/heiheiru
* branch master -> FETCH_HEAD
fatal: refusing to merge unrelated histories

Try

$ git pull --allow-unrelated-histories origin master

$ git push origin master

Article author: Andrei Olegovich

Banner image