How do I get git to default to ssh and not https for new repositories

后端 未结 6 732
慢半拍i
慢半拍i 2020-12-04 04:40

These days when I create a new repository on GitHub on the setup page I get:

git remote add origin https://github.com/nikhilbhardwaj/abc.git
git push -u orig         


        
6条回答
  •  温柔的废话
    2020-12-04 04:57

    The response provided by Trevor is correct.

    But here is what you can directly add in your .gitconfig:

    # Enforce SSH
    [url "ssh://git@github.com/"]
      insteadOf = https://github.com/
    [url "ssh://git@gitlab.com/"]
      insteadOf = https://gitlab.com/
    [url "ssh://git@bitbucket.org/"]
      insteadOf = https://bitbucket.org/
    

提交回复
热议问题