在git push / pull命令中跳过输入用户名和密码

时间:2016-04-24 02:03:48

标签: git command-line

任何人都知道如何设置它,所以当我在命令行中,当我push/pull进出git存储库时,我不必输入我的用户名和密码?

感谢。

1 个答案:

答案 0 :(得分:4)

当您使用http/https作为转移协议时,系统会要求您username&每次password

切换到ssh键,您将不再被问到。

以下示例是如何为GitHub设置密钥,但对于大多数具有微小更改(GUI)的服务器,我将是相同的。

流程仍然相同

  • 生成ssh-key
  • 将密钥添加到服务器
  • 将协议更改为ssh(git://

<强> Here is how to set it up:

  • 生成一个新的ssh密钥(如果您已经有一个密钥,则跳过此步骤)
    ssh-keygen -t rsa -C "your@email"

  • 将密钥设置在home/.ssh目录(或Windows下的Users/<your user>.ssh)后,打开它并将内容复制到中央存储库下的相关部分(ssh密钥)。 / p>

<强> For more information about the transport protocols read this:

<强> How to set up ssh key under your GitHub account?

  • 登录GitHub帐户
  • 点击右上角的牧场主( Settings enter image description here
  • 点击SSH keys and GPG Keys
    enter image description here
  • 点击New SSH key
    enter image description here
  • 粘贴您的密钥并保存

现在它应该工作

<强> Note

首次设置打开终端并运行git fetch后,密钥将被测试并添加到您的known hosts文件中。

相关问题