Git 中更改远程仓库(remote)的 URL 相关操作步骤如下:
- 首先使用
git remote -v
命令查看当前仓库的远程仓库列表,输出如下:
origin https://github.com/username/repository.git (fetch)
origin https://github.com/username/repository.git (push)
- 使用
git remote set-url
命令更改远程仓库的 URL。例如,如果要将 URL 更改为https://github.com/new-username/repository.git
,则执行以下命令:
git remote set-url origin https://github.com/new-username/repository.git
- 使用
git remote -v
命令再次查看远程仓库列表,确认 URL 是否已更改:
origin https://github.com/new-username/repository.git (fetch)
origin https://github.com/new-username/repository.git (push)
现在,远程仓库的 URL 已成功更改。