如何在服务器上克隆、pull、push GitHub私有项目
å¦ä½å¨æå¡å¨ä¸å éãpullãpush GitHubç§æé¡¹ç®
诸ç¥ç¼é»ä¸è¯ 2026-08-22 0 é 读2åé诸ç¥ç¼é»ä¸è¯-ä¸ªäººææ¯åæä¸è§é¢ç®å½
ææ¯å¨æ¬å°çµèä¸ä¿®æ¹ãå¼ååºç¨ä»£ç ï¼ç¶åæ³æ¨éå°GitHubç§æä»åºï¼å¹¶å¨æå¡å¨ä¸ç´æ¥å
éãç¼è¾ãæ´æ°å¯¹åºç项ç®ã
ç°å¨GitHubæ2FA认è¯äºï¼ææ¯ç´æ¥ç¨è°·ææµè§å¨åçPasskeyãè¿åæå°±ä¸ä»ç»äºãæ»ä¹æ¬æå°±åªè®²personal access tokençäºï¼
ææ§è¡git cloneå½ä»¤åï¼ä¼æç¤ºè®©æè¾å
¥GitHubè´¦å·å¯ç ã以忝å¯ä»¥ç´æ¥è¾å
¥è´¦å·å¯ç çï¼ä½æ¯ç°å¨æè¾å
¥è´¦å¯åå®è¿æ¯æ¾ç¤ºå
é失败ï¼å¹¶æ¾ç¤ºï¼
ï¼2024å¹´12æçææï¼ï¼
Cloning into 'folder_name'...
Username for 'https://github.com': user_name
Password for 'https://user_name@github.com':
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/user_name/folder_name.git/'
ï¼2026å¹´8æçææï¼ï¼
remote: Invalid username or token. Password authentication is not supported for Git operations.
fatal: Authentication failed for 'https://github.com/user_name/folder_name.git/'
ä¹å°±æ¯è¯´ç°å¨ä¸æ¯æä» ç¨è´¦å·å¯ç æ¥å éGitHub项ç®äºï¼è§£å³æ¹æ¡æ¯å¨è¾å ¥å¯ç æ¶æ¹ä¸ºè¾å ¥personal access tokenãè·åpersonal access tokençæ¹å¼ï¼
- è¿å
¥github.com/settings/peâ¦
ç°å¨personal access tokenåæfine-grainedåclassic两ç§ã
ææå·®ä¸å¤ï¼æå°±åªä»ç»fine-grained tokenäºã - å建tokenï¼
- æå®tokenåç§°ï¼ä¼å¨tokenå表ä¸çå°ï¼æ¹ä¾¿æç¡®åªä¸ªtokenæ¯æ¿æ¥å¹²ä»ä¹äºçï¼ãtokenæè¿°ãè¿ææ¶é´ãrepositoryèå´åæéï¼æ³è¦æ£å¸¸æ§è¡cloneãpullçæä½å°±å¾ç»ä»£ç 读åæéï¼ã
è¿ä¸ªresource owneræä¹ä¸ç¥éé¤äºèªå·±è¿è½éè°ï¼æå°±æ¯ç»èªå·±ç¨çï¼æä»¥è¿æ²¡æä»ç»ç ç©¶ã
- çæpersonal access tokenåç¹å»å¤å¶å³å¯ï¼æ³¨æè¿ä¸ªtokenåªä¼çæä¸æ¬¡ï¼å¨token详æ
çé¢ä¸ä¹ä¸è½å¤å¶ï¼
å¨token详æ çé¢ä¸å¯ä»¥ç»æã
Aitishiku.com