如何存储多个PATs/密码供git使用? [英] How to store multiple PATs/passwords for use by git?
问题描述
我想安全地"存储我的凭据.供 git
使用,所以我按照指示进行了操作此处.这样,我不必每次都输入密码/PAT,我可以执行任何git操作.
I wanted to store my credentials "safely" for use by git
so I did as instructed
here. This way I don't have to input password/PAT every single time, I perform any git operation.
-
使用
sudo apt-get安装libsecret-1-0 libsecret-1-dev
构建凭据管理器"使用 sudo make --directory =/usr/share/doc/git/contrib/credential/libsecret
Build the "credential manager" using sudo make --directory=/usr/share/doc/git/contrib/credential/libsecret
,然后使用 git config --global credential.helper \/usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret
配置我的本地git文件夹
and then configure my local git folder using git config --global credential.helper \ /usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret
做工精湛.
我不知道的是如何对许多密码进行相同的操作具有不同的帐户/存储库.建议我使用gcm核心.
What I don't get is how to do the same for many passwords associated with different accounts/repositories. I was suggested to use gcm core.
我尝试按照此处的指示安装 gcm core
a>.
I tried installing gcm core
as instructed here.
-
下载.deb软件包
Download .deb package
sudo dpkg -i<包装路径>git-credential-manager-core配置
配置凭据存储" git config credential.credentialStore secretservice
(因为我使用libsecret).
configure the "credential store" git config credential.credentialStore secretservice
(as I use libsecret).
我删除了指向以下代码的 Credential helper
/usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret
从本地git配置文件中获取.
I removed the Credential helper
pointing to
/usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret
from the local git config file.
它仍然不起作用.当我尝试推送一个回购协议时,出现乱码提示如何使用 git config
的消息,然后要求填写凭据(在此处中显示).我不明白我在做什么!分别是 credential store
, credential manager
, secret-service
和 gcm core
.
It still doesn't work. When I try to push a repo, I get a garbled
message with how to use git config
followed by request to fill in
credentials (shown here). I don't understand what I am doing! namely credential store
, credential manager
, secret-service
and gcm core
.
I looked here and here and I still don't get it.
推荐答案
任何凭据帮助者都应遵循相同的过程.
Any credential helper should follow the same process.
但是,如果您在同一个域中有多个帐户/密码(例如github.com),那么您需要更改远程URL
But if you have multiple account/password for the same domain (say github.com for instance), then you need to change your remote URL
cd /path/to/my/local/repo1
git remote set-url origin https://user1@github.com/user1/myRepo1
^^^^^^
cd /path/to/my/local/repo2
git remote set-url origin https://user2@github.com/user1/myRepo2
^^^^^^
这样,凭据助手将区分您的不同帐户.
由于gcm core的安装有点麻烦,因此请首先使用基于libsecret的经典帮助程序对其进行测试.
That way, the credential helper will differentiate your different account.
Since gcm core is a bit fineky to install, test it first with the classic libsecret-based helper.
这篇关于如何存储多个PATs/密码供git使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!