sourcetree中添加賬號和密碼托管服務器有限, 無法使用其他的url 地址添加賬號 , 不管怎么設置就是拉取不到項目. 拉取時提示:
git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks -c credential.helper= -c credential.helper="C:/
解決辦法:
使用ssh key 方法直接獲取該項目的權限
1、進入~路徑下,必須保證當前路徑在~路徑下
在git命令行敲擊 ssh-keygen -t rsa -C "xxx.@yyy.zzz" //建議寫自己真實有效的郵箱地址。注意:在敲代碼是不要將雙引號也敲擊進去。
然后命令行會出現如下代碼:
Enter file in which to save the key (/c/Users/xxxx_000/.ssh/id_rsa): //此時我們什么都不需要操作,直接回車就好
Enter passphrase (empty for no passphrase): //此時要你輸入碼(可以為空,直接回車就好,也可以輸入你的密碼,這個密碼在你最后把本地資源推送到github上面的時候回會讓你填寫密碼,此時密碼隱藏,你輸入進去是看不到的)
Enter same passphrase again: //再次確認密碼(如果你第一次有輸入密碼,這次就再輸一次,如果沒有直接回車就行了)
Your identification has been saved in /c/Users/xxxx_000/.ssh/id_rsa. //生成的密鑰
Your public key has been saved in /c/Users/xxxx_000/.ssh/id_rsa.pub. //生成的公鑰
The key fingerprint is:
e3:51:33:xx:xx:xx:xx:xxx:61:28:83:e2:81 xxxxxx@yy.com
*本機已完成ssh key設置,其存放路徑為:c:/Users/xxxx_000/.ssh/下。其中xxxx_000為你的用戶名。
2、添加ssh key 到Github上
首先登陸Github,點擊右上角的“▼”→Settings→SSH kyes→Add SSH key。
然后在打開c:/Users/xxxx_000/.ssh里面的id_rsa.pub文件,全選復制公鑰內容
也可以在git bush中的命令行輸入cat ~/.ssh/id_rsa.pub,將得到公鑰
Title自定義,將公鑰粘貼到GitHub中Add an SSH key的key輸入框,最后“Add Key“
3、配置賬戶
$ git config --global user.name “your_username” #設置用戶名
$ git config --global user.email “your_registered_github_Email” #設置郵箱地址(建議用注冊giuhub的郵箱)
4、測試ssh keys是否設置成功。
ssh -T git@github.com
The authenticity of host 'github.com (192.30.252.129)' can't be established.
RSA key fingerprint is 16:27:xx:xx:xx:xx:xx:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes #確認你是否繼續聯系,輸入yes
Warning: Permanently added 'github.com,192.30.252.129' (RSA) to the list of known hosts.
Enter passphrase for key '/c/Users/xxxx_000/.ssh/id_rsa': #生成ssh kye是密碼為空則無此項,若設置有密碼則有此項且,輸入生成ssh key時設置的密碼即可。
Hi xxx! You've successfully authenticated, but GitHub does not provide shell access. #出現此句話,說明設置成功。
到這里,git相關的所有配置已經完成,
此步驟完成后,如果在本地拉取代碼就不需要輸入密碼.
接下來配置sourceTree: 工具 =>選項
將其改為OpenSSH 此時就會自動拿去到ssh key ,這樣就能跳過密碼獲取項目的權限;
!!!!!!填坑成功!!!!!!!!!!