在不影响分支的情况下替换 git 遥控器
Replace a git remote without affecting branches
我正在开发一个项目,由于 DevOps 的变化,突然需要重新连接到远程(使用新的 URL)。我需要采取哪些步骤来删除旧的遥控器并与新的遥控器建立连接而不破坏我未合并的分支?
我尝试使用以下方式更新遥控器 URL:
git remote set-url origin codecommit::us-west-2://myrepo
但是从 master 获取时出现这个错误:
fatal: repository 'https://git-codecommit.us-west-2.amazonaws.com/v1/repos/myrepo/' not found
我是不是漏掉了什么?
作为背景,我曾经使用的 CodeCommit 存储库已更改为需要联合访问。所以我想使用 git-remote-codecommit (GRC) 和相应的 URL 而不是旧的标准 HTTPS URL.
首先,在改变原点之前,你可以检查一个URL是否可以用于:
git ls-remote <newURL>
您可以在任何地方执行该命令,只要它不能完全正常工作...您无需担心 git remote set-url origin
。
其次,我知道这个 codecommit AWS endpoints (HTTPS or SSH),但不知道“联合”。
仔细检查“Using Federated Identities with AWS CodeCommit”中描述的过程,尤其是/home/ec2-user/.aws
目录内容。
OP Mossi adds in :
Turned out the IAM role that the AWS Credential Helper needed had disappeared from my environment variables.
I added it back and I was able to connect to the repo using the GRC URL. In short set-url
was the solution.
我正在开发一个项目,由于 DevOps 的变化,突然需要重新连接到远程(使用新的 URL)。我需要采取哪些步骤来删除旧的遥控器并与新的遥控器建立连接而不破坏我未合并的分支?
我尝试使用以下方式更新遥控器 URL:
git remote set-url origin codecommit::us-west-2://myrepo
但是从 master 获取时出现这个错误:
fatal: repository 'https://git-codecommit.us-west-2.amazonaws.com/v1/repos/myrepo/' not found
我是不是漏掉了什么?
作为背景,我曾经使用的 CodeCommit 存储库已更改为需要联合访问。所以我想使用 git-remote-codecommit (GRC) 和相应的 URL 而不是旧的标准 HTTPS URL.
首先,在改变原点之前,你可以检查一个URL是否可以用于:
git ls-remote <newURL>
您可以在任何地方执行该命令,只要它不能完全正常工作...您无需担心 git remote set-url origin
。
其次,我知道这个 codecommit AWS endpoints (HTTPS or SSH),但不知道“联合”。
仔细检查“Using Federated Identities with AWS CodeCommit”中描述的过程,尤其是/home/ec2-user/.aws
目录内容。
OP Mossi adds in
Turned out the IAM role that the AWS Credential Helper needed had disappeared from my environment variables.
I added it back and I was able to connect to the repo using the GRC URL. In short
set-url
was the solution.