å½ä½¿ç¨HTTPSåè®®æ¨é代ç å°Gitä»åºæ¶ï¼åç°æ¯æ¬¡é½éè¦è¾å
¥å¯ç ï¼æä½èµ·æ¥é常麻ç¦ãä¸é¢ä»ç»å ç§å
å»è¾å
¥å¯ç çæ¹æ³ã
HTTPSåè®®æ¨é
使ç¨HTTPSåè®®ï¼æä¸ç§ç®åç²æ´çæ¹å¼æ¯å¨è¿ç¨å°åä¸å¸¦ä¸å¯ç ã
> git remote set-url origin
http://yourname:[email protected]/yourname/project.gitè¿æä¸ç§æ¹æ³ï¼æ¯å建æ件åå¨Git
ç¨æ·ååå¯ç ã
以Windowsç¯å¢ä¸ºä¾ï¼å¨%USERPROFILE%ç®å½ä¸ï¼ä¸è¬ä¸ºC:\Users\yourname)ï¼æå¼Git Bash
å½ä»¤è¡ï¼å建æ件
> touch .git-credentials
å¨æ件ä¸è¾å
¥ä»åºååï¼è¿é使ç¨äºbitbucket
.orgã
https://yourname:[email protected]å¨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
[email protected]:<ç¨æ·å>/çæ¬åºå
æè
> git remote -v
> git remote set-url origin
[email protected]:<ç¨æ·å>/çæ¬åºå
æ§è¡æ¨éã
> 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
å°±å¯ä»¥æ¨éæåäºã