1

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?

Hasani
  • 3,543
  • 14
  • 65
  • 125

2 Answers2

3

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
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

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.

Phil Dukhov
  • 67,741
  • 15
  • 184
  • 220
  • 1
    Welcome to Stack Overflow. Code-only answers are discouraged on Stack Overflow because they don't explain how it solves the problem. Please edit your answer to explain what this each of these commands does and how it solves the problem, so that it is useful to the OP as well as other users with similar issues. – FluffyKitten Aug 18 '20 at 19:19