How can I change the remote/target repository URL on Windows? [duplicate]

How can I change the remote/target repository URL on Windows? [duplicate]

This question already has an answer here:

How to change the URI (URL) for a remote Git repository?

15 answers

I created a local GIT repository on Windows. Let’s call it AAA. I staged, committed, and pushed the contents to GitHub.
I realized I made a mistake with the name.
On GitHub, I renamed it to
Now, on my Windows machine, I need to change to because the settings are still trying to “push” to but I need to push to now.
How could I do that?


Solution 1:

The easiest way to tweak this in my opinion (imho) is to edit the .git/config file in your repository. Look for the entry you messed up and just tweak the URL.

On my machine in a repo I regularly use it looks like this:

KidA% cat .git/config 
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    autocflg = true
[remote "origin"]
    url = ssh://localhost:8888/opt/local/var/git/project.git
    #url = ssh://
    fetch = +refs/heads/*:refs/remotes/origin/*

The line you see commented out is an alternative address for the repository that I sometimes switch to simply by changing which line is commented out.

This is the file that is getting manipulated under-the-hood when you run something like git remote rm or git remote add but in this case since its only a typo you made it might make sense to correct it this way.

Solution 2:

git remote set-url origin <URL>

Solution 3:

One more way to do this is:

git config remote.origin.url

To see the existing URL just do:

git config remote.origin.url

Solution 4:

Take a look in .git/config and make the changes you need.

Alternatively you could use

git remote rm [name of the url you sets on adding]


git remote add [name] [URL]

Or just

git remote set-url [URL]

Before you do anything wrong, double check with

git help remote