0

我有一个 beaglebone,我在不久前(当我第一次学习 git 时)设置了一个用于特定 github 帐户的 ssh 密钥。该帐户是我们公司的主帐户。许多人直接在 beaglebone 上工作,并直接从 beaglebone 推送到 github。我想更改设置,以便每当有人想要提交或推送到 github 时,都会询问他们的用户名。

我最近的提交和推送看起来像这样......你会看到我没有输入用户名的选项,只有我们公司主帐户的密码。

root@beaglebone:/var/lib/cloud9/pypos# git commit -a -m "class restructured and passing the new updated test script"
[class_restructure 1db2e33] class restructured and passing the new updated test script
 2 files changed, 14 insertions(+), 10 deletions(-)
root@beaglebone:/var/lib/cloud9/pypos# git push origin class_restructure
Enter passphrase for key '/home/root/.ssh/id_rsa':
Counting objects: 7, done.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 531 bytes, done.
Total 4 (delta 3), reused 0 (delta 0)
To git@github.com:FarmDesign/pypos.git
   83831a8..1db2e33  class_restructure -> class_restructure
root@beaglebone:/var/lib/cloud9/pypos#
4

1 回答 1

3

GitHub 支持与您在那里托管的存储库进行通信的不同协议。如果您使用 SSH 协议,那么 git 会要求您输入密码以解锁存储在 .ssh 中的密钥,这与推送到 GitHub 存储库的能力相关(任何有权访问该密钥的人都可以推送到存储库,因此提供只需要访问密钥的密码)。但是,如果您使用 HTTP,则会要求您提供 GitHub 用户名和密码。

因此,请转到存储库的 GitHub 网页,并注意存储库 URL 旁边(靠近页面顶部)的 HTTP、SSH 和 GIT 切换按钮。使用该按钮来查看 repo 的 URL 是如何变化的——这些是根据您使用的协议可以访问您的 repo 的不同 URL。现在,单击“HTTP”并将该 URL 复制到剪贴板。

现在,转到您的终端并 cd 到您本地克隆的 repo 目录。现在,使用 git remote 命令更改 git 将与 GitHub 存储库通信的 URL:

git remote set-url origin THE_URL_THAT_YOU_JUST_COPIED_TO_CLIPBOARD

现在,当您尝试执行 git push 时,git 将使用 HTTP 协议,该协议将要求您指定用户名和密码。

于 2013-04-13T11:21:12.433 回答