Ever start a git repo using a password, then later upgrade to an ssh key? And then find out you can't push to it, no matter how hard you try? Even when you're sure that all of your ssh keys are set up correctly?
This might have happened to you in the last few years because both github and bitbucket require ssh keys! But some of have repos we started long before that with passwords.
I was finally able to push my work to the repo!
I was realllly stuck.... and getting nervous because I couldn't push my changes...but fortunately I learned about having multiple remotes at work...
And remembered a detail about git from a previous job...
Basically: If you check out a repo with one method, e.g. password, you can't push
to that URL with a different method, e.g. ssh key! Knowing that I was still kinda screwed with my password-method checkout ...
Until I attempted to add a second remote to it! the second remote was an ssh-key-based URL...
and then all I had to do was:
git add remote sshrem <blag long URL here.git> # note that sshrem is just a local temp name
git push sshrem
That's
it! it pushed right up! Now with that behind me, I am back in business developing new
sounds for my musical instrument, the Brooklyn Eel!!
BTW, here's a super useful command for showing the remotes in detail:
git remote -v