Hasani
Hasani

Reputation: 3929

fatal: remote origin already exists. , fatal: No such remote:

I tried

git remote add origin https://github.com/rezaee/confusion-last.git

and got

fatal: remote origin already exists..

Then tried

git push -u origin master

but got:

warning: redirecting to https://github.com/rezaee/confusion.git/
To http://github.com/rezaee/confusion.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'http://github.com/rezaee/confusion.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

So I tried

git remote remove https://github.com/rezaee/confusion-last.git

but got

fatal: No such remote: 'https://github.com/rezaee/confusion-last.git'.

How is it possible?

Upvotes: 1

Views: 6683

Answers (2)

you can try below git commands:

After git initialization you can add the repo and then try set the url from the git site by below command

git remote set-url origin

Once origin set try your repo url

git remote set-url origin [https: your repo link from git]

Check whether the url you set are present inside the master or not

git remote -v

Now you can push your repo to github

git push -u origin master

Sometimes set-url works when add don't, so try these above commands.

Upvotes: 0

VonC
VonC

Reputation: 1329032

It is possible because git remote remove looks for a remote alias name, not the actual URL.

git remote remove origin

That would have worked.

However, your remote is already set to another URL (see git remote -get-url origin).
To change it without having to remove it:

git remote set-url origin https://github.com/rezaee/confusion-last.git

Upvotes: 3

Related Questions