Hans
Hans

Reputation: 11

Remove incorrectly written URL from git remote push URL

I have got this situation:

$ git remote show origin
* remote origin
  Fetch URL: [email protected]:/gruprog-20/hansji-p-uppgift.git
  Push  URL: https://github.com/kulkarninomizuproduct/p-uppgift.git
  Push  URL: ^C
  Push  URL: ^C
  Push  URL: [email protected]:/gruprog-20/hansji-p-uppgift.git
  HEAD branch: master
  Remote branch:
    master tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (fast-forwardable)

This happened when i tried to copy some things, and the "^C" got accidently added as a push URL to my remote called "origin" when i pressed ctrl+C (though I never pressed enter). I have tried many different commands to remove it:

$ git remote remove ^C
$ git remote rm ^C
$ git remote rm url ^C
$ git remote set-url --delete --push ^C
$ git remote set-url --delete ^C
$ git remote set-url --delete --push <^C>
$ git remote set-url --delete --push origin ^C

I suspect that the URL isnt actually "^C" but the actual command ctrl+C because look at this difference:

#When I write "git remote rm", then ctrl+C (as above, I dont need to press enter)(it returns nothing):

$ git remote rm ^C


# When I write "git remote ^C"

$ git remote rm ^C
fatal: No such remote: '^C'

Upvotes: 0

Views: 735

Answers (1)

steadweb
steadweb

Reputation: 16551

You need to specify the remote you want to remove, so origin in this case, like so:

git remote remove origin

You can also use set-url to change the remote URL (change URL for actual origin git/https URL):

git remote set-url origin URL

If both of those aren't working for you, you can manually edit the following file from the root of the project:

.git/config

Which should have the contents like so:

[remote "origin"]
        url = ...
        fetch = +refs/heads/*:refs/remotes/origin/*

Upvotes: 1

Related Questions