如何配置git以将我的用户推送到GitHub?

时间:2016-04-21 20:20:03

标签: git github

当我提交并从命令行推送时,git push提交到github但是提交它不是来自我的github用户。当我从intellij github执行此操作时需要用户名和密码,所有提交都链接到我的帐户。我该如何配置?

2 个答案:

答案 0 :(得分:1)

我找到了这个例子here

$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com

您还需要在本地计算机上设置SSH密钥。 Here's如何完成任务。

答案 1 :(得分:0)

使用ssh / git协议,您将不再使用密码。

以下是设置方法:

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

  • 将密钥设置在home/.ssh目录(或Windows下的Users/<your user>.ssh)后,打开它并复制内容

如何将sh键添加到github帐户?

  • 登录github帐户
  • 点击右上角的牧场主(设置)
    enter image description here
  • 点击SSH keys
    enter image description here
  • 点击Add ssh key
    enter image description here
  • 粘贴您的密钥并保存

你们都准备出发了: - )

相关问题