Table of contents

Git error fatal: No such remote 'origin'

Git Mar 24, 2020 Viewed 243 Comments 0


On my computer, I run some commands to create git repository. 

$ mkdir test
$ cd test
$ git init
$ echo '' > index
$ git add index
$ git commit -m "init"

And I want to push to remote server. So I create an empty repository on server. Run it.

$ git init --bare --shared test.git
Initialized empty shared Git repository in /develop/git/test.git/

On my computer, I try to use set-url to modify the remote of the repository, and I get an error.

$ git remote set-url origin ssh://user@
fatal: No such remote 'origin'


When I running git remote -v, no addresses are displayed. So I need to add, not modify. Run:

$ git remote add origin ssh://user@

After running git remote -v again, I can see the links of fetch and push.

$ git remote -v
origin	ssh://user@ (fetch)
origin	ssh://user@ (push)

Then push to server.

$ git push --set-upstream origin master
Updated Mar 24, 2020