Measure twice, cut once

A quick post about an issues I had recently when starting the next project on my course. This issues isn't to do with the project but an issue with the repository...and a lesson in taking your time.

It's not my first repository or working with Git, but I'd been rushing around and was paying more attention to what herbs and spices I was going to use in my curry than the process of cloning a repo. Done that 100s of times, no problem. But this time...

...Support for password authentication was removed on August 13, 2021. 
Please see https://docs.github.com/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication. 
fatal: Authentication failed for 'repo url'

The error message was clear, GitHub no longer supports password authentication. Before heading to the url I remembered having to use the Personal Access Token (PAT), and that I had then changed the tools I was using to avoid passwords altogether and use SSH keys instead.

The Fix

I realised that in my rush I'd just grabbed the first url available to me for the repo. I'd cloned using the HTTPS url and needed the SSH url. A quick search of the docs and found a command I don't rememebr using much before.

I found that I could check the current url with the following command:

# git remote -v
> origin  https://github.com/user/repo.git (fetch)
> origin  https://github.com/user/repo.git (push)

I then used the following command to update the url:

# git remote set-url origin git@github.com:user/repo.git

I then checked the url again:

# git remote -v
> origin  git@github.com:user/repo.git (fetch)
> origin  git@github.com:user/repo.git (push)

And that was it. I was able to push and pull from the repo without any issues.