macÔõôװÖÃgithub
mac ϵͳÏÂ×°Öà github
GitHub ÊdzÌÐòÔ±Ãdz£ÓõĴúÂëÍйÜƽ̨֮һ£¬Ëü²»µ«ÌṩÁËÃâ·ÑµÄ´úÂëÍйÜЧÀÍ£¬»¹¿ÉÒÔͨ¹ý Pull Request¡¢Issues µÈ¹¦Ð§ÊµÏÖÍŶÓÐ×÷¿ª·¢¡£ÏÂÃæÏÈÈÝÔÚ Mac ϵͳÏÂÔõÑù×°Öà GitHub¡£
°ì·¨Ò»£ºÏÂÔØ×°Öà Git
Ê×ÏÈ£¬Òª×°Öà Git£¬ÓÉÓÚ Git ÊÇ GitHub ʹÓõİ汾¿ØÖƹ¤¾ß¡£·¿ªÖնˣ¬ÊäÈëÒÔÏÂÏÂÁ
$ brew install git
µÇ¼ºó¸´ÖÆ
ÈôÊÇûÓÐ×°Öà Homebrew£¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁî×°Öãº
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
µÇ¼ºó¸´ÖÆ
×°ÖÃÍê³Éºó£¬¿ÉÒÔÊäÈëÒÔÏÂÏÂÁî¼ì²é Git ÊÇ·ñÒѾÀÖ³É×°Öãº
$ git --version
µÇ¼ºó¸´ÖÆ
ÈôÊÇ·ºÆð Git °æ±¾ÐÅÏ¢£¬ËµÃ÷ Git ×°ÖÃÀֳɡ£
°ì·¨¶þ£ºÌìÉú SSH ÃÜÔ¿
½ÓÏÂÀ´£¬ÐèÒª½¨ÉèÓë GitHub ЧÀÍÆ÷Ö®¼äµÄ SSH ÅþÁ¬£¬ÓÃÓÚÉí·ÝÑéÖ¤£¬ÒÔÈ·±£ÄúµÄ´úÂë±»´«Êäµ½ºÏÊʵĿÍÕ»¡£
ÔÚÖÕ¶ËÖУ¬ÊäÈëÒÔÏÂÏÂÁ
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
µÇ¼ºó¸´ÖÆ
Õâ¸öÏÂÁî»áʹÓà RSA Ëã·¨ÌìÉúÒ»¸ö³¤¶ÈΪ 4096 µÄ SSH ÃÜÔ¿£¬ÆäÖÐ “your_email@example.com” Ó¦Ì滻ΪÄã×Ô¼ºµÄµç×ÓÓʼþµØµã¡£ÔÚ´ËÀú³ÌÖУ¬¿ÉÒÔÊäÈëÔÊÐí»ò²»ÔÊÐí SSH »á¼ûµÄÃÜÂ룬»òÕßƾ֤СÎÒ˽ÈËÐèÇóÖ±½Ó°´»Ø³µÌø¹ý¡£
µ±ÃÜÔ¿ÌìÉúºó£¬¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁîÉó²é²¢¸´ÖÆÄúµÄ¹«Ô¿£º
$ cat ~/.ssh/id_rsa.pub
µÇ¼ºó¸´ÖÆ
°ì·¨Èý£ºÌí¼Ó SSH ÃÜÔ¿
½ÓÏÂÀ´£¬½«¹«Ô¿Ìí¼Óµ½ GitHub ÉÏ£¬ÒÔÔÊÐí GitHub ÅбðÄúµÄÍâµØÅÌËã»úÒÔ¼°ÔÊÐíÄú»á¼ûÓëÄúµÄÕÊ»§¹ØÁªµÄ´æ´¢¿â¡£
µÇ¼ GitHub ÕÊ»§£¬µ¥»÷Í·Ïñ£¬È»ºóÑ¡Ôñ¡°Settings¡±£¨ÉèÖã©¡£Ñ¡Ôñ×ó²àµ¼º½Öеġ°SSH keys¡±£¨SSH ÃÜÔ¿£©²¢µ¥»÷¡°Add SSH Key¡±£¨Ìí¼Ó SSH ÃÜÔ¿£©¡£
ÔÚ¡°Title¡±×Ö¶ÎÖÐÊäÈëÒ»¸öÃû³Æ£¬È»ºóÔÚ¡°Key¡±×Ö¶ÎÖÐÕ³Ìù¹«Ô¿¡£×îºó£¬µ¥»÷¡°Add SSH Key¡± °´Å¥¼´¿É¡£
°ì·¨ËÄ£ºÑéÖ¤ SSH ÅþÁ¬
Ìí¼Ó SSH ÃÜÔ¿ºó£¬¿ÉÒÔÑéÖ¤ SSH ÅþÁ¬ÊÇ·ñÀֳɡ£ÔÚÖÕ¶ËÖÐÊäÈëÒÔÏÂÏÂÁ
$ ssh -T git@github.com
µÇ¼ºó¸´ÖÆ
ÈôÊÇÅþÁ¬Àֳɣ¬»á·ºÆðÒÔÏÂÀàËƵÄÊä³ö£º
Hi username! You've successfully authenticated, but GitHub does not provide shell access.
µÇ¼ºó¸´ÖÆ
°ì·¨Î壺ÉèÖà Git Óû§ÃûºÍÓÊÏä
È·±£ÄúÒѾÉèÖÃÁËÍâµØ Git Óû§ÃûºÍÓÊÏ䣬ÓÉÓÚÕâЩÐÅÏ¢½«±»¼Í¼ΪÌá½»µÄÀúÊ·ÐÅÏ¢Ö®Ò»¡£ÔÚÖÕ¶ËÖÐÊäÈëÒÔÏÂÏÂÁîÀ´ÉèÖÃÄúµÄÓû§ÃûºÍµç×ÓÓʼþ£º
$ git config --global user.name "Your Name" $ git config --global user.email "your_email@example.com"
µÇ¼ºó¸´ÖÆ
ÏÖÔÚÄúÒѾÀÖ³É×°Öò¢ÉèÖÃÁË GitHub¡£¿ÉÒÔͨ¹ý Git ÏÂÁîÐлòʹÓà Git ¿Í»§¶ËÀ´Óë GitHub ¿ÍÕ»¾ÙÐÐÐ×÷¡£
½áÂÛ
ÒÔÉϾÍÊÇÔÚ mac ϵͳÏÂ×°Öà github µÄÕû¸öÀú³Ì¡£×°Öà Git¡¢ÌìÉú SSH ÃÜÔ¿¡¢Ìí¼Ó SSH ÃÜÔ¿¡¢ÑéÖ¤ SSH ÅþÁ¬¡¢ÉèÖà Git Óû§ÃûºÍÓÊÏäÕâЩ°ì·¨£¬¶¼ÊDZز»¿ÉÉٵġ£Í¨¹ýÕâÑù×°ÖúÍÉèÖã¬Äã¿ÉÒÔÔÚÍâµØÅÌËã»úÉÏÓä¿ìµØÓë GitHub ¿ÍÕ»¾ÙÐÐÐ×÷¿ª·¢¡£
ÒÔÉϾÍÊÇmacÔõôװÖÃgithubµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡