【问题标题】:Git (1.7.10) asks me every time for username and passwordGit(1.7.10)每次都询问我用户名和密码
【发布时间】:2012-06-13 07:15:40
【问题描述】:

由于我有新版本,它不再询问我在 ssh 密钥文件中设置的密码。

当我每次推送时,它现在直接询问 github 用户名和密码。

这是 git 的一个新特性还是过去改变了它,还是 github 上有什么改变了?

我尝试使用 ssh 以及我的 ssh 密钥文件中的电子邮件和密码进行身份验证,并且成功了。

GitHub 更改为 smartftp 并更改了设置 repos 的说明

https://github.com/blog/1104-credential-caching-for-wrist-friendly-git-usage

https://help.github.com/articles/create-a-repo

后来看到了,他们现在默认使用https而不是git协议

【问题讨论】:

  • 通过运行git remote -v 检查您的遥控器是否真的配置为gitssh 访问。您可能无意中从https 克隆。否则,这不应该是必需的。
  • 我看到 github 更改了设置 repos 的文档,请参见第 3 步:help.github.com/articles/create-a-repo 他们在此之前使用 https,它只是 git@github.com ...

标签: git version-control github ssh credentials


【解决方案1】:

前几天我从 GitHub 上的新存储库说明中剪切和粘贴时遇到了这个问题。应该有人提交错误报告,因为它几乎让我认识的每个人都感到困惑。

问题在于说明告诉您创建一个使用 https 协议而不是 git 协议的远程。我通常使用:

github_username=CodeGnome
git remote add origin "git@github.com:${github_username}/${PWD##*/}.git"
git push --tags --set-upstream origin master

从预先存在的本地存储库中填充新的 GitHub 存储库。

【讨论】:

  • github.com/blog/… 似乎他们写了一篇关于它的博客文章,但没有提到替换说明
  • 所以目前我们每次都必须输入用户名和密码(github认为智能http是未来,我们应该使用它吗?)?但优点是,我们可以每次设置当前想要的用户名,这样我们就不会从错误的 github 帐户推送 =)
  • @DanielRuf 如果您使用智能 HTTP,则可以在 Windows 和 OS X 上使用凭证缓存。请参阅 stackoverflow.com/a/10962447/1301972
【解决方案2】:
git config --global credential.helper cache
git config --global credential.helper 'cache --timeout=3600'

你只在第一次推送时输入你的用户名和密码;在3600s或1小时后,你在没有用户名和密码的情况下推送。

超时你可以设置你的号码。

【讨论】:

    【解决方案3】:

    使用 https 地址,您还有另一种选择(除了password caching):
    HOME 中使用_netrc 文件,其中包含您的用户名和密码(或.netrc 用于bash 会话)。
    请注意,默认情况下没有为 Windows 定义 HOME。

    machine github.com
    login <login_github>
    password <password_github>
    

    另见“Git - How to use .netrc file on windows to save user and password”。

    (“Syncing with github”处的其他选项)

    【讨论】:

    • 我有点喜欢这样,但带有密码的纯文本文件似乎并不特别安全。整个事情似乎在某种程度上倒退了。
    • @Thufir 在我的商店中,我们通过将%HOME% 定义在远程磁盘上来缓解“纯文本”问题(如“Z:`" for instance), putting our _netrc` 文件在那里。你仍然可以加密它如果你愿意:stackoverflow.com/questions/5193643/…
    猜你喜欢
    • 2012-07-09
    • 2021-01-27
    • 2012-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-10
    • 2021-04-07
    • 1970-01-01
    相关资源
    最近更新 更多