ÔõÑùÔÚGitÖÐÉèÖÃÄ¿½ñÕ˺Å
ÎÒÃÇÔÚʹÓÃgit¾ÙÐа汾¿ØÖƵÄʱ¼ä£¬³£³£»áÓöµ½ÐèÒªÇл»²î±ðµÄgitÕ˺ŵÄÇéÐΡ£ºÃ±È£¬ÎÒÃÇ¿ÉÄÜÐèÒªÔÚ²î±ðµÄ¿ÍÕ»ÖÐʹÓòî±ðµÄgitÕ˺ţ¬»òÊÇÐèÒªÔÚ²î±ðµÄÍŶÓÖÐʹÓòî±ðµÄgitÕ˺š£
ÄÇô£¬ÔõÑùÔÚGitÖÐÉèÖÃÄ¿½ñÕ˺ÅÄØ£¿±¾ÎĽ«Îª¸÷ÈËÏÈÈÝGitÖÐÄ¿½ñÕ˺ŵÄÉèÖÃÒªÁì¡£
µÚÒ»²½£º½¨ÉèSSH Key
ÈôÊÇÄ㻹ûÓÐÔÚÍâµØÅÌËã»úÉϽ¨ÉèSSH Key£¬ÄÇôÄãÐèÒªÊ×ÏÈÖ´ÐÐÕâÒ»°ì·¨¡£ÈôÊÇÒѾ½¨ÉèÁËSSH Key£¬¿ÉÒÔÌø¹ý±¾°ì·¨¡£
·¿ªÖնˣ¨»òGit Bash£©£¬ÊäÈëÒÔÏÂÏÂÁ
ssh-keygen -t rsa -C "ÄãµÄÓÊÏä"
µÇ¼ºó¸´ÖÆ
ÆäÖУ¬¡°ÄãµÄÓÊÏ䡱ÐèÒªÌæ»»³ÉÄãµÄGitHubÕ˺Ű󶨵ÄÓÊÏäµØµã¡£
½Ó×Å»áÌáÐÑÄãÉèÖÃSSH KeyµÄÉúÑÄλÖúÍÊäÈëÃÜÂëµÈÐÅÏ¢£¬ÕâЩ¿ÉÒÔƾ֤СÎÒ˽ÈËϲ»¶À´ÉèÖá£
Íê³Éºó£¬¿ÉÒÔÔÚ~/.sshÎļþ¼ÐÏÂÕÒµ½id_rsaºÍid_rsa.pubÁ½¸öÎļþ£¬Õâ¾ÍÊÇÎÒÃÇÐèÒªµÄSSH Key¡£
µÚ¶þ²½£º½«SSH Key Ìí¼Óµ½GitHubÕ˺Å
ÔÚGitHubÉÏÌí¼ÓSSH Key£¬Ê¹ÊÊÍâµØÅÌËã»úºÍGitHubÕ˺ÅÖ®¼ä½¨ÉèÅþÁ¬¡£
Ê×ÏÈ£¬µÇ¼ÄãµÄGitHubÕ˺ţ¬µã»÷Ò³ÃæÓÒÉϽǵÄСÎÒ˽ÈËÍ·Ïñ£¬ÔÚÏÂÀ²Ëµ¥ÖÐÑ¡Ôñ¡°Settings¡±£¨ÉèÖã©¡£
ÔÚÒ³Ãæ×ó²àÀ¸ÖÐÕÒµ½¡°SSH and GPG keys¡±£¨SSHºÍGPGÃÜÔ¿£©£¬µã»÷¡°New SSH key¡±£¨Ð½¨SSH¼ü£©¡£
ÔÚµ¯³öµÄ´°¿ÚÖÐÊäÈëÒ»¸öÎÊÌ⣨ÓÃÓÚÐÎòÍâµØÅÌËã»ú£©£¬ÔÚ¡°Key¡±×Ö¶ÎÖÐÕ³ÌùÉÏÒ»²½ÌìÉúµÄid_rsa.pubÎļþÄÚÈÝ¡£
Íê³Éºó£¬µã»÷¡°Add SSH key¡±°´Å¥£¬¼´¿ÉÀÖ³ÉÌí¼ÓSSH Key¡£
µÚÈý²½£ºÉèÖÃÄ¿½ñÕ˺Å
ÔÚÍâµØÅÌËã»úÉÏ£¬·¿ªÖնˣ¨»òGit Bash£©£¬ÊäÈëÒÔÏÂÏÂÁ
git config --global user.name "ÄãµÄÓû§Ãû" git config --global user.email "ÄãµÄÓÊÏä"
µÇ¼ºó¸´ÖÆ
ÆäÖУ¬¡°ÄãµÄÓû§Ãû¡±ºÍ¡°ÄãµÄÓÊÏ䡱»®·Ö¶ÔÓ¦×ÅÄãGitHubÕ˺ŵÄÓû§ÃûºÍ°ó¶¨µÄÓÊÏäµØµã¡£
ÈôÊÇÒªÉèÖÃÒ»¸ö²î±ðµÄÕ˺ţ¬ÔÚ¿ÍÕ»ÖÐʹÓã¬Ö»ÐèÒªÔÚÒÔÉÏÏÂÁîÖÐÈ¥µô–global£¬¼´¿ÉÕë¶ÔÄ¿½ñ¿ÍÕ»¾ÙÐÐÉèÖá£
Íê³ÉÒÔÉÏ°ì·¨ºó£¬¼´¿ÉÀÖ³ÉÉèÖÃÄ¿½ñÕ˺š£ÔÚʹÓÃGit¾ÙÐа汾¿ØÖÆʱ£¬¾Í¿ÉÒÔ×Ô¶¯Ê¶±ðÄ¿½ñʹÓõÄÕ˺ţ¬²¢Æ¾Ö¤ÉèÖþÙÐвÙ×÷¡£
ÐèҪעÖصÄÊÇ£¬ÉèÖÃÍêÕ˺źó£¬ÎÒÃÇÔÚʹÓÃGitʱӦµ±°ü¹Ü²Ù×÷µÄÒ»ÖÂÐÔ£¬×èÖ¹ÒýÆð»ìÏý¡£Í¬Ê±£¬ÈôÊÇÐèÒª±ä»»Õ˺ţ¬¿ÉÒÔÖظ´ÒÔÉÏ°ì·¨¾ÙÐÐÉèÖá£
×ܽá
ÉèÖÃGitÄ¿½ñÕ˺ţ¬ÊÇʹÓÃGit¾ÙÐа汾¿ØÖƵĻù´¡²Ù×÷Ö®Ò»¡£Í¨¹ý½¨ÉèSSH Key¡¢Ìí¼Óµ½GitHubÕ˺š¢ÉèÖÃÍâµØÕ˺ŵȰ취£¬ÎÒÃÇ¿ÉÒÔÀû±ãµØÖÎÀí²î±ðµÄGitÕ˺ţ¬²¢Æ¾Ö¤ÐèÒª¾ÙÐÐÇл»¡£ÔÚʹÓÃGitÀú³ÌÖУ¬ºÏÀíµØÉèÖÃÄ¿½ñÕ˺ţ¬¿ÉÒÔ°ü¹Ü´úÂëµÄÇå¾²ÐԺͲÙ×÷µÄÒ»ÖÂÐÔ£¬Ìá¸ß¿ª·¢Ð§ÂÊ¡£
ÒÔÉϾÍÊÇÔõÑùÔÚGitÖÐÉèÖÃÄ¿½ñÕ˺ŵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡