0

I am mid-development into a project and due to DevOps changes there is suddenly the need to re-connect to the remote (with a new URL). What are the steps that I need to take to remove the old remote and establish connection with the new one without ruining my unmerged branches?

I have tried updating the remote URL using:

git remote set-url origin codecommit::us-west-2://myrepo

but getting this error when fetching from master:

fatal: repository 'https://git-codecommit.us-west-2.amazonaws.com/v1/repos/myrepo/' not found

Am I missing something?

As background, the CodeCommit repo that I used to work with has been changed to require federated access. So I want to use git-remote-codecommit (GRC) with the corresponding URL instead of the old standard HTTPS URL.

Mossi
  • 997
  • 5
  • 15
  • 28
  • @1615903 `git remote set-url` doesn't seem to work unfortunately. Doing fetch gives this error: fatal: repository "https://git-codecommit..../" not found – Mossi May 11 '21 at 04:08
  • That means your repository URL is wrong, not that set-url doesn't work. – 1615903 May 11 '21 at 04:11
  • @1615903 You're right. The credentials weren't being recognized by the new remote. I fixed it and was able to connect. – Mossi May 11 '21 at 18:34

1 Answers1

1

First, before changing origin, you can check if an URL work with:

git ls-remote <newURL>

You can execute that command anywhere, and as long as it does not fully work... you don't need to worry about git remote set-url origin.

Second, I know about this codecommit AWS endpoints (HTTPS or SSH), but not about "federated".
Double-check the process described in "Using Federated Identities with AWS CodeCommit", especially the /home/ec2-user/.aws directory content.

The OP Mossi adds in the comments:

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • This was helpful. 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. – Mossi May 11 '21 at 18:33
  • Great! Well done. – VonC May 11 '21 at 19:39