Git Push - 远程URL中的用户名和密码

Cha*_*ila 8 git push github

通过在远程推送网址中添加用户名:密码,可以避免推送到github时的密码提示.

https://you:password@github.com/you/example.git
Run Code Online (Sandbox Code Playgroud)

这是github特定的安排还是可以使用这种格式(https://username:password@somedomain.org/repo.git)与任何git遥控器?

Had*_*OMA 7

通过 GitHub 对您进行身份验证而不是将您的密码放在远程 URL 中的一种更安全的方法是,如果您使用 HTTPS,则在GitHub 页面中生成一个新令牌,然后像这样构建您的远程 URL:

https://<username>:<token>@github.com/<username>/<project_name>.git
Run Code Online (Sandbox Code Playgroud)


Cri*_*scu 4

这是github的具体安排吗?

它不是特定于 Github 的;这实际上是基本 HTTP 身份验证。诀窍user:password@host在 URL 中指定 BA 凭据的方法

...这种格式可以用于任何 git 远程吗( https://username:password@somedomain.org/repo.git )?

它仅适用于使用 HTTP 协议的遥控器。对于 SSH 远程,您必须使用 SSH 密钥。