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

前端 未结 25 2067
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 00:28

I have a repo (origin) on a USB key that I cloned on my hard drive (local). I moved \"origin\" to a NAS and successfully tested cloning it from here.

I would like to

25条回答
  •  悲哀的现实
    2020-11-22 01:18

    git remote set-url origin git://new.location
    

    (alternatively, open .git/config, look for [remote "origin"], and edit the url = line.

    You can check it worked by examining the remotes:

    git remote -v
    # origin  git://new.location (fetch)
    # origin  git://new.location (push)
    

    Next time you push, you'll have to specify the new upstream branch, e.g.:

    git push -u origin master
    

    See also: GitHub: Changing a remote's URL

提交回复
热议问题