如何为 git pull 输入带有密码的命令? [英] How to enter command with password for git pull?

查看:16
本文介绍了如何为 git pull 输入带有密码的命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在一行中执行此命令:

I want to do this command in one line:

git pull && [my passphrase]

怎么做?

推荐答案

这不是你要求的,而是 http(s):

This is not exactly what you asked for, but for http(s):

  • 您可以将密码放在 .netrc 文件中(Windows 上为 _netrc).从那里它将被自动拾取.它会以 600 个权限进入您的主文件夹.
  • 您也可以使用 https://user:pass@domain/repo 克隆存储库,但这并不是真正推荐的,因为它会在很多地方显示您的用户/密码...
  • 一个新选项是使用 凭证助手.请注意,凭据将使用标准凭据帮助程序以明文形式存储在本地配置中.带有 wincred 的 credential-helper 也可以在 Windows 上使用.
  • you can put the password in .netrc file (_netrc on windows). From there it would be picked up automatically. It would go to your home folder with 600 permissions.
  • you could also just clone the repo with https://user:pass@domain/repo but that's not really recommended as it would show your user/pass in a lot of places...
  • a new option is to use the credential helper. Note that credentials would be stored in clear text in your local config using standard credential helper. credential-helper with wincred can be also used on windows.

凭证助手的使用示例

  • git config credential.helper store - 无限期地存储凭证.
  • git config credential.helper 'cache --timeout=3600'- 存储 60 分钟
  • git config credential.helper store - stores the credentials indefinitely.
  • git config credential.helper 'cache --timeout=3600'- stores for 60 minutes

对于基于 ssh 的访问,您可以使用 ssh 代理,该代理将在需要时提供 ssh 密钥.这需要在您的计算机上生成密钥,将公钥存储在远程服务器上并将私钥添加到相关的密钥库中.

For ssh-based access, you'd use ssh agent that will provide the ssh key when needed. This would require generating keys on your computer, storing the public key on the remote server and adding the private key to relevant keystore.

这篇关于如何为 git pull 输入带有密码的命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆