我使用this method来添加多个远程存储库URL。我错误地使用此命令两次添加了相同的远程url:
git remote set-url origin --push --add <a remote>现在,git remote -v展示了以下内容:
origin https://github.com/<user>/<repo>.git (fetch)
origin https://github.com/<user>/<repo>.git (push) // remote-1
origin https://github.com/<user>/<repo>.git (push) // duplicate reference to same remote-1
origin https://bitbucket.com/<user>/<repo>.git (push) // remote-2 所以现在,每当我推,git推3次,假设有3个URL。
如何删除这个重复的URL,同时保留原始的&新的远程引用。
发布于 2021-01-06 14:23:55
你可以用这样的方法
git remote set-url --push --delete origin <url>,然后只添加一次URL。
关于set-url的git文档声明:
设置-url更改远程的url。为与regex匹配的远程设置第一个URL (如果不给出第一个URL )。如果不匹配任何URL,则会发生错误,并且不会发生任何更改。
使用-- push,push URL被操纵,而不是获取URL。
使用--add,而不是改变现有的URL,添加新的URL。
使用--delete,而不是更改现有的URL,所有匹配regex的URL都会被删除。试图删除所有非推送URL是一个错误。
因此,我们可以将--push和--delete参数组合起来,以实现我们想要的结果。
https://stackoverflow.com/questions/65597320
复制相似问题