Git 1.8.0支持与gnome-keyring的集成.
http://www.h-online.com/open/news/item/Git-1-8-0-can-access-Windows-and-GNOME-keyrings-1733879.html
阅读有关git凭证助手的文档后:http://git-scm.com/docs/gitcredentials.html
我无法找到使用此新功能的方法.我该如何整合它?我正在使用Archlinux和从Archlinux的存储库安装的git.(git 1.8.0)
Jam*_*ard 181
@ marcosdsanchez的答案是Arch(它回答了原始问题),但我在Ubuntu上.对于git> = 2.11:
sudo apt-get install libsecret-1-0 libsecret-1-dev
cd /usr/share/doc/git/contrib/credential/libsecret
sudo make
git config --global credential.helper /usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret
Run Code Online (Sandbox Code Playgroud)
对于git <2.11:
sudo apt-get install libgnome-keyring-dev
cd /usr/share/doc/git/contrib/credential/gnome-keyring
sudo make
git config --global credential.helper /usr/share/doc/git/contrib/credential/gnome-keyring/git-credential-gnome-keyring
Run Code Online (Sandbox Code Playgroud)
mar*_*hez 52
Git 1.8.0附带了gnome-keyring支持,但需要为您的平台编译二进制文件.
这就是Archlinux为我解决的问题:
$ sudo pacman -S libgnome-keyring
$ cd /usr/share/git/credential/gnome-keyring
$ make
$ git config --global credential.helper /usr/share/git/credential/gnome-keyring/git-credential-gnome-keyring
Run Code Online (Sandbox Code Playgroud)
@VonC解决方案已关闭,但git config命令应该指向可执行文件.这就是为什么它不适合我.
Von*_*onC 23
2016年第4季度更新:
Unix,Mac(Git 2.11+)
git config --global credential.helper libsecret
Run Code Online (Sandbox Code Playgroud)(请参阅" 使用Git凭证助手时出错gnome-keyring ")
视窗:
git config --global credential.helper manager
Run Code Online (Sandbox Code Playgroud)(请参阅" 如何在Windows登出Git中的Bash控制台? ":这是混帐的Windows使用了最新的Microsoft Git的凭据管理器用于Windows)
原始答案(2012)
适用于Windows,Mac和Unix平台的Credential Helpers首先在"git-credential-helper"repo中引入,现在已经包含在git发行版中:
此存储库包含一组Git凭证帮助程序(
gitcredentials(7)),它们是git(或将来的贡献)的一部分.
$ git clone git://github.com/pah/git-credential-helper.git
$ BACKEND=gnome-keyring # or any other backend
$ cd git-credential-helper/$BACKEND
$ make
$ cp git-credential-$BACKEND /path/to/git/crendential
Run Code Online (Sandbox Code Playgroud)
在构建时,它将安装在/path/to/git/credential目录中.
要使用此后端,可以通过设置将其添加到(全局)Git配置中
(这里是Unix):
git config --global credential.helper /path/to/git/credential/gnome-keyring/git-credential-gnome-keyring
Run Code Online (Sandbox Code Playgroud)
Windows注意事项:
我想你可以在Windows上运行一个程序并调用像pypi keyring 0.10这样的库.
但这是后端,你不直接从Git使用它.
你正在使用的是"凭证助手"(反过来,它将调用它在Windows上所需的任何凭证API).
GitHub for Windows提供了这样一个帮助程序(作为一个名为... github的可执行文件),并且可以在Windows会话期间存储您的凭据.
从"GitHub for Windows"窗口启动一个shell,你会看到,键入"git config --system -l":
C:\Users\VonC\Documents\GitHub\test [master +2 ~0 -0 !]> git config --system -l
credential.helper=!github --credentials
Run Code Online (Sandbox Code Playgroud)
该credential.helper=!github --credentials部分将调用凭证助手' github'.
$ git config [--global] credential.helper $BACKEND
Run Code Online (Sandbox Code Playgroud)
vk5*_*5tu 11
2018年10月更新
GNOME已弃用libgnome-keyring并将其替换为libsecret.提交https://github.com/git/git/commit/87d1353a6a添加了新的凭证帮助程序/ usr/libexec/git-core/git-credential-libsecret.
git config --global credential.helper libsecret
Sup*_*reg 10
对于Fedora上的任何人,我略微编辑了James Ward的回答:
sudo yum install libgnome-keyring-devel
cd /usr/share/doc/git/contrib/credential/gnome-keyring
sudo make
git config --global credential.helper /usr/share/doc/git/contrib/credential/gnome-keyring/git-credential-gnome-keyring
Run Code Online (Sandbox Code Playgroud)
只需将这两行添加到您的~/.gitconfig文件中:
[credential]
helper = gnome-keyring
Run Code Online (Sandbox Code Playgroud)
下次Git要求您输入密码时,输入的密码将保存到Gnome Keyring(您可以通过seahorse工具查看),之后不再要求您输入密码.
这假设您的Git版本足够新(如2.1.0)并且您使用的是Linux Fedora,RHEL或CentOS.对于旧版本或其他操作系统/发行版,请查看其他答案.