简体   繁体   English

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

[英]Difference between git@github.com:… and https://github.com/…?

I've recently attempted building a project which had various dependencies declared as Github links. 我最近尝试构建一个项目,该项目具有声明为Github链接的各种依赖项。 The links were a mixture of links to public Github repositories and private Github Enterprise repositories of my company. 链接是公共Github存储库和我公司的私有Github Enterprise存储库的链接的混合。

Some of the links were in format 一些链接是格式化的

https://github.com/project/repo.git

And some were in format 还有一些是格式化的

git@github.com:project/repo.git

What exactly is the difference between such formats and which format is intended to be used for what purpose? 这些格式之间究竟有什么区别?哪种格式用于什么目的?

git can operate on a variety of different protocols git可以在各种不同的协议上运行

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

It uses the port 443 (or 80 for http), it allows both read and write access, password for auth (like on github it allows anonymous read access but asks a paasword for write).and Firewall friendly (it does not require any infra configuration). 它使用端口443(或80用于http),它允许读取和写入访问,密码用于身份验证(就像在github上它允许匿名读取访问但要求写入paasword)。并且防火墙友好(它不需要任何infra组态)。

ssh like git@github.com:project/repo.git sshgit@github.com:project / repo.git

It uses the port 22, it allows both read and write access, requires SSH Keys for auth so if you give git your public ssh key, your ssh protocol will use your private key for authentication with git, so you will not need to provide a username password. 它使用端口22,它允许读写访问,需要SSH密钥验证,所以如果你给你的公共ssh密钥,你的ssh协议将使用你的私钥与git进行身份验证,所以你不需要提供用户名密码。

with SSH you will not be asked to provide your password each time you use the git push command as the ssh protocol will use you private key for authentication with the repository. 使用SSH时,每次使用git push命令时都不会要求您提供密码,因为ssh协议将使用私钥对存储库进行身份验证。

https://github.com/project/repo.git

is HTTPS URL 是HTTPS URL

git@github.com:project/repo.git

is SSH URL 是SSH URL

both can be used to do git file transfers but github recommends HTTPS over SSH URLs because These URLs work everywhere--even if you are behind a firewall or proxy. 两者都可用于执行git文件传输,但github建议通过SSH URL进行HTTPS,因为这些URL可以在任何地方使用 - 即使您位于防火墙或代理之后。

refer https://help.github.com/articles/which-remote-url-should-i-use/ for more information. 有关更多信息,请参阅https://help.github.com/articles/which-remote-url-should-i-use/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM