git@github.com:...和https://github.com/...之间的区别?

Ser*_*nik 2 git github repository

我最近尝试构建一个项目,该项目具有声明为Github链接的各种依赖项.链接是公共Github存储库和我公司的私有Github Enterprise存储库的链接的混合.

一些链接是格式化的

https://github.com/project/repo.git
Run Code Online (Sandbox Code Playgroud)

还有一些是格式化的

git@github.com:project/repo.git
Run Code Online (Sandbox Code Playgroud)

这些格式之间究竟有什么区别?哪种格式用于什么目的?

小智 6

git可以在各种不同的协议上运行

http(s)https://github.com/project/repo.git

它使用端口443(或80用于http),它允许读取和写入访问,密码用于身份验证(就像在github上它允许匿名读取访问但要求写入paasword).和防火墙友好(它不需要任何infra组态).

sshgit@github.com:project/repo.git

它使用端口22,它允许读写访问,需要SSH密钥验证,所以如果你给你的公共ssh密钥,你的ssh协议将使用你的私钥与git进行身份验证,所以你不需要提供用户名密码.

使用SSH时,每次使用git push命令时都不会要求您提供密码,因为ssh协议将使用私钥对存储库进行身份验证.