Happy New Year, everyone. I’ll keep it short today. I wrote a little shell function to help me switch my GitHub repo remote URLs between protocols. As you know, GitHub has two methods of access, HTTPS and SSH. Sometimes you’ll clone a repo using one protocol but want to use the other one. This nifty script will handle that for you.
You can place the above code into your dotfiles for quick use. I have mine in .zshrc. Then, simply run
github_remote_switch inside your git repo folder, and the script will switch the protocol around for you.
No warranty, but it was tested working on zsh on macOS 10.12. It’s basic bash so it should be portable across UNIX-like systems.
Let me know how it works out for you!