source tree每次push都需要密码的解决方法

Windows
首先可以考虑使用GitHub for Windows,它已经包含了该助手,或者可以下载对应系统的版本:Windows 7、Windows 8、Source 版本,然后解压缩文件并将里面的git-credential-winstore.exe 放到git 所在的目录运行即可。下次再 commit 的时候,会弹出个窗口询问用户名和密码,填写一次即可永久保存了。注意,一定要将 git-credential-winstore.exe 复制到 git 所在目录。

Mac
安装 osxkeychain凭据助手,并在 Git 中设置使用。注意,Git 版本需要 1.7.9 及以上才可使用。如果已经安装了homebrew,那么应该已经自带了osxkeychain。
一、测试凭据助手是否安装
git credential-osxkeychain
如果已安装,控制台会显示如下:

usage: git credential-osxkeychain <get|store|erase>

如果没有安装,那么可以使用curl下载并安装:
$ curl -s -O http://github-media-downloads.s3.amazonaws.com/osx/git-credential-osxkeychain    # Download the helper
$ chmod u+x git-credential-osxkeychain     # Fix the permissions on the file so it can be run

接下来,将osxkeychain安装到与Git安装目录相同的位置:
$ which git     # Find where git is installed
/usr/local/git/bin/git
$ sudo mv git-credential-osxkeychain /usr/local/git/bin/     # Move the file so git can access it
Password: [enter your password]

然后,在Git的全局配置中进行设置:
$git config --global credential.helper osxkeychain

执行如下命名后,第一次git push需要密码,后续都不需要了
git config --global credential.helper osxkeychain

猜你喜欢

转载自www.cnblogs.com/94pm/p/11090357.html
今日推荐