如果你用git從遠程pull拉取代碼,每次都要輸入密碼,那么執行下面命令即可
git config --global credential.helper store
這個命令則是在你的本地生成一個賬號密碼的本子似的東東,這樣就不用每次都輸入了(但是還得輸入一次)
Git同步它人的遠程倉庫至自己的Git服務器 並自動定時更新
https://blog.csdn.net/qq_28387069/article/details/78757346
----------------
方法1:
使用HTTPS協議,有一種簡單粗暴的方式是在遠程地址中帶上密碼。
> git remote set-url origin http://yourname:password@bitbucket.org/yourname/project.git
還有一種方法,是創建文件存儲Git用戶名和密碼。
以Windows環境為例,在%USERPROFILE%目錄中(一般為C:\Users\yourname),打開Git Bash命令行,創建文件
> touch .git-credentials
在文件中輸入倉庫域名,這里使用了bitbucket.org。
https://yourname:password@bitbucket.org
方法2:
在CMD終端中設置在全局Git環境中,長期存儲密碼
> git config --global credential.helper store
其他設置密碼方式
記住密碼(默認15分鍾):git config --global credential.helper cache
自定義存儲時間:git config credential.helper 'cache --timeout=3600'
SSH協議推送
如果原來的推送地址協議是HTTPS,可以通過換成SSH協議,在遠程倉庫添加SSH Key來實現推送時免賬戶密碼輸入。
> git remote -v // 查看遠程地址
> git remote rm origin // 刪除原有的推送地址
> git remote add origin git@github.com:<用戶名>/版本庫名
或者
> git remote -v
> git remote set-url origin git@github.com:<用戶名>/版本庫名
執行推送。
> git push -u origin master
發現提示權限不夠。
The authenticity of host 'bitbucket.org (104.192.143.1)' can't be established.
RSA key fingerprint is SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'bitbucket.org,104.192.143.1' (RSA) to the list of kn
own hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
需要在本地創建該帳號的RSA Key。可以參考以下兩篇文章:
Windows下配置SSH連接Github
Git如何在本地生成多個SSH key
然后再執行推送。
> git push -u origin master
就可以推送成功了。