使GIT使用凭证存储在GitHub客户端中(或直接存储在GIT中)

发布于 2025-01-19 08:05:03 字数 464 浏览 4 评论 0原文

为了启用 github 存储库上的推送,我应该使用“令牌身份验证”。

创建令牌后,我应该将其存储在本地 github 客户端中。 https: //docs.github.com/en/get-started/getting-started-with-git/caching-your-github-credentials-in-git

如何让我的本地 github 客户端与本地 git 交互?我只想使用 git push 到我的 github 存储库并使用存储的令牌进行身份验证。

或者,我会省略本地 github 客户端并将令牌直接存储在 git 中,但我不知道如何实现这一点。

In order to enable pushing on a github repo, I am supposed to use "Token Authentication".

After creating a token, I am supposed to store this in my local github client. https://docs.github.com/en/get-started/getting-started-with-git/caching-your-github-credentials-in-git.

How do I make my local github client then interact with my local git? I simply want to use git pushto my github repo and use the stored token to authenticate.

Alternatively, I would ommit the local github client and store the token directly in git, but I did not find out how to achieve that.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

荒芜了季节 2025-01-26 08:05:03

Git 没有用于存储凭据的内置存储,而是依赖“凭据管理器”来存储凭据并在需要时反馈它们。

最常见的凭证管理器是 Git Credentials Manager (GCM)(以前称为 gcm-core)。它可以配置为将凭据存储在操作系统安全存储中或将其加密存储在磁盘上。

curl -LO https://raw.githubusercontent.com/GitCredentialManager/git-credential-manager/main/src/linux/Packaging.Linux/install-from-source.sh &&
sh ./install-from-source.sh &&
git-credential-manager-core configure

或者,如果您依赖适用于 Linux 的 Windows 子系统,您也可以将其搭载在 Windows 凭据存储上。

在您的 .gitconfig 添加:

git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-manager-core.exe"
git config --global credential.https://dev.azure.com.useHttpPath true

更多详细信息:

Git doesn't have a builtin store for storing credentials, it instead relies on 'credential managers' to store the credentials and feed them back when needed.

The most common credential manager is the Git Credentials Manager (GCM) (formerly gcm-core). It can be configured to store the credentials in your operating systems secure store or to store them encrypted on disk.

curl -LO https://raw.githubusercontent.com/GitCredentialManager/git-credential-manager/main/src/linux/Packaging.Linux/install-from-source.sh &&
sh ./install-from-source.sh &&
git-credential-manager-core configure

Or if you rely on Windows Subsystem for Linux you can have it piggyback on the Windows credential store as well.

In your .gitconfig add:

git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-manager-core.exe"
git config --global credential.https://dev.azure.com.useHttpPath true

More details:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文