【问题标题】:store git passwd in local [duplicate]将git密码存储在本地[重复]
【发布时间】:2022-01-05 06:12:50
【问题描述】:

我有一个 git 远程存储库以及上面的用户名和密码。
当我克隆我的仓库时,因为它内部有很多子仓库。每次我都必须输入我的用户名和密码。
我只能从 git 服务器读取。
如何永久存储我的用户名和密码以使用远程仓库?

【问题讨论】:

标签: git git-remote


【解决方案1】:

您可以将 ssh 密钥添加到 ssh-agent。这将记住 ssh 密码,这样您就不必每次都输入它了。请参阅 GitHub 文档了解如何执行此操作:https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#adding-your-ssh-key-to-the-ssh-agent

【讨论】:

  • 我无权访问 git 服务器。
  • 我只能从 git 服务器读取。
【解决方案2】:

你可以使用

git config --global credential.helper store

或者在终端中执行以下命令,将git凭证助手配置为缓存模式,

git config --global credential.helper cache

“gitcredentials”模块用于向用户请求这些凭据并存储这些凭据以避免重复输入这些凭据。

默认情况下,“存储”模式下的 git 凭据将存储在 用户主目录(~/.git-credentials)中的“.git-credentials”文件

在 Windows 中,路径是 C:\Users\<username>\.git-credentials

在 Mac 和 Linux 中,路径是 /Users/<username>/.git-credentials

有关更多信息和选项,您可以阅读this essaythis document on git-scm.com

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-28
    • 2017-03-23
    • 2018-07-27
    • 2020-07-20
    • 2021-11-14
    • 2013-06-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多