Git: globally change GitHub-remotes from git@ to https
Does your IDE or composer set remote repositories to ssh rather than https? Or are repositories you are using set up that way? You are not alone. Let's fix it once and for all!
Setting upstreams
Are you finding yourself using git remote --add --push
-commands not to actually change the location, but to fix authentication problems with GitHub arising from using ssh instead of https? There is a simple solution.
The format of the ssh-url is
git@github.com:[userOrOrg]/[repoName].git, while we want it to behttps://github.com/[userOrOrg]/[repoName].git
That is very predictable, so you can run the following command:
git config --global url."https://github.com/".insteadOf git@github.com:
Note the trailing slash as well as the colon!
Yes, that simple!
That's it. You can verify (and change) the setting by inspecting the global configuration:
git config --global --edit