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

后端 未结 6 736
慢半拍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:58

    • GitHub

      git config --global url.ssh://git@github.com/.insteadOf https://github.com/
      
    • BitBucket

      git config --global url.ssh://git@bitbucket.org/.insteadOf https://bitbucket.org/
      

    That tells git to always use SSH instead of HTTPS when connecting to GitHub/BitBucket, so you'll authenticate by certificate by default, instead of being prompted for a password.

提交回复
热议问题