There are far worse gotchas in the “make a new clone” approach. It’s “simpler” only if you haven’t made any stashes, haven’t made any local branches, don’t have any un-pushed commits, and don’t have a rebase or merge in progress. If you have any of those, you need to migrate them to the new cloned repo, which for partial rebases & merges is way more complicated than a few minor config changes.
Amongst them are that one needs to change the character after
That applies to git remote paths (
host.name:/path/to/repo), but does not apply to
git+ssh URLs (
git+ssh://host.name/path/to/repo). Just change the
git+ssh: (and do not change or remove any
I said “replace the URL”, meaning the whole URL, exactly to avoid the implication that it should be chopped about. On the contrary, as the replacement just use the URL that was to going to be used to create a new clone.
On the whole I like @airtower-luna 's answer best, though for me personally I’m happier editing a text configuration file rather than trying to remember all the correct commands. And I can leave the old version as a comment in the config file, in case I screw up.
(The subtlety I alluded to is that it only works for regular repos, not for gists. For gists you need to change the hostname to just
github.com and remove the username. And for some really old git repos you might need to trim any trailing
/ and/or add
PS: in case you’re wondering, yes
ssh+git: are completely interchangeable. Use whichever you’re comfortable with.