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

This question already has an answer here:

  • Change the URI (URL) for a remote Git repository 11 answers

  • 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 
    [core]
        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://xxx.xxx.xxx.xxx:80/opt/local/var/git/project.git
        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.


    git remote set-url origin <URL>
    

    One more way to do this is:

    git config remote.origin.url https://github.com/abc/abc.git
    

    To see the existing URL just do:

    git config remote.origin.url
    
    链接地址: http://www.djcxy.com/p/4614.html

    上一篇: 如何在IP地址更改后访问git remote repo

    下一篇: 我如何在Windows上更改远程/目标存储库URL?