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

前端 未结 25 2598
爱一瞬间的悲伤
爱一瞬间的悲伤 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:08

    You have a lot of ways to do that:

    Console

    git remote set-url origin [Here new url] 
    

    Just be sure that you've opened it in a place where a repository is.

    Config

    It is placed in .git/config (same folder as repository)

    [core]
        repositoryformatversion = 0
        filemode = false
        bare = false
        logallrefupdates = true
        symlinks = false
        ignorecase = true
    [remote "origin"]
        url = [Here new url]  <------------------------------------
    ...
    

    TortoiseGit

    Then just edit URL.

    SourceTree

    1. Click on the "Settings" button on the toolbar to open the Repository Settings window.

    2. Click "Add" to add a remote repository path to the repository. A "Remote details" window will open.

    3. Enter a name for the remote path.

    4. Enter the URL/Path for the remote repository

    5. Enter the username for the hosting service for the remote repository.

    6. Click 'OK' to add the remote path.

    7. Back on the Repository Settings window, click 'OK'. The new remote path should be added on the repository now.

    8. If you need to edit an already added remote path, just click the 'Edit' button. You should be directed to the "Remote details" window where you can edit the details (URL/Path/Host Type) of the remote path.

    9. To remove a remote repository path, click the 'Remove' button

    ref. Support

提交回复
热议问题