案例:
本地Gitlab仓库,从http://192.168.1.122/test/data.git下载的gitlab仓库,想重新关联到新的https://192.168.1.123/test/data.git的远程仓库去
具体操作示例:
步骤 1:进入本地仓库目录
cd /path/to/your/local/repository
步骤 2:查看当前的远程仓库配置
git remote -v
这会显示当前关联的远程仓库地址(通常是 origin
),例如:
origin http://192.168.1.122/test/data.git (fetch) origin http://192.168.1.122/test/data.git (push)
步骤 3:修改远程仓库地址
使用 git remote set-url
命令更新远程仓库地址:
git remote set-url origin https://192.168.1.123/test/data.git
步骤 4:验证是否修改成功
再次运行 git remote -v
,确认地址已更新:
git remote -v
输出应变为:
origin https://192.168.1.123/test/data.git (fetch) origin https://192.168.1.123/test/data.git (push)