Or
git remote set-url origin git@github.com:...
Or using URL replacements in git config. git remote set-url origin git@github.com:...
Or using URL replacements in git config. # ~/.ssh/config
Host github_ssh
HostName github.com
User git
IdentityFile ~/.ssh/my_github_key
> git remote add github github_ssh:Username/RepoName.git
This has worked reliably for me for quite a while now.The custom hostname will be replaced transparantly for you and won't need to make it into gitmodules.
# ~/.config/git/config
# Only for single user/org
[url "git@github_ssh:foo"]
insteadOf = "git@github.com:foo"
# all the things
[url "git@github_ssh"]
insteadOf = "git@github.com"
Similar pattern if you want to force-use ssh instead of https or vice-versa.