Ïê½âmacÉÏÔõô´î½¨GitHubÇéÐÎ
Ëæ×ÅÊÖÒÕµÄÆÕ¼°ºÍ¿ªÔ´µÄʱ´úÀ´ÁÙ£¬¸ü¶àµÄÈË×îÏȹØ×¢github¡£×÷ΪȫÇò×î´óµÄ¿ªÔ´ÉçÇøºÍ°æ±¾¿ØÖÆÖÎÀíƽ̨£¬github ÊdzÌÐòÔ±±Ø±¸µÄ¹¤¾ß£¬ËüÀû±ãÁË´úÂëµÄ´æ´¢ºÍÖÎÀí£¬Ò²Àû±ãÁË´úÂëµÄ½»Á÷ºÍ¹²Ïí¡£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚ mac µçÄÔÉϴ github µÄÇéÐΡ£
µÚÒ»²½£¬×°Öà Git
Git ÊÇÒ»¸öÃâ·Ñ¡¢¿ªÔ´µÄÂþÑÜʽ°æ±¾¿ØÖÆϵͳ£¬ÆäÖ÷Òª×÷ÓÃÊǶÔÔ´´úÂë¾ÙÐÐÖÎÀí¡£ÔÚ Mac µçÄÔÉÏ×°Öà Git ÊǴ GitHub ÇéÐεÄÐëÒª°ì·¨¡£
Ê×ÏÈ·¿ªÄãµÄÖնˣ¬Ê¹ÓÃÒÔÏÂÏÂÁî×°Öà Homebrew¡£
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
µÇ¼ºó¸´ÖÆ
½Ó×ÅʹÓÃÒÔÏÂÏÂÁî×°Öà Git¡£
brew install git
µÇ¼ºó¸´ÖÆ
×°ÖÃÍê³Éºó£¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÑéÖ¤ÊÇ·ñ׼ȷװÖÃÁË Git¡£
git --version
µÇ¼ºó¸´ÖÆ
µÚ¶þ²½£¬×¢²á GitHub Õ˺Å
ÔÚʹÓà GitHub ֮ǰ£¬ÄãÐèÒªÏÈ×¢²áÒ»¸ö GitHub Õ˺š£»á¼û[GitHub¹ÙÍø](https://github.com/)£¬µã»÷ÓÒÉϽǵġ°Sign up¡±×¢²á°´Å¥£¬Æ¾Ö¤ÌáÐÑÍê³É×¢²á¡£
ÈôÊÇÄãÒѾӵÓÐÁË GitHub Õ˺ţ¬ÄÇô¿ÉÒÔÖ±½Ó¾ÙÐÐÏÂÒ»²½¡£
µÚÈý²½£¬½¨ÉèÍâµØ¿ÍÕ»
½¨ÉèÍâµØ¿ÍÕ»²¢ÈÃËüÓë GitHub ÖеĿÍÕ»ÏàÅþÁ¬£¬ÕâÊǴ GitHub ÇéÐεÄÒªº¦°ì·¨¡£
Ê×ÏÈÔÚÍâµØ½¨ÉèÒ»¸öĿ¼£¬ÀýÈ磺ÔÚ×ÀÃæÉϽ¨ÉèÒ»¸öÃûΪ¡°GitHub¡±µÄÎļþ¼Ð¡£
ÔÚÖÕ¶ËÖÐʹÓà cd ÏÂÁî½øÈë¸ÃĿ¼¡£
cd ~/Desktop/ mkdir GitHub cd GitHub/
µÇ¼ºó¸´ÖÆ
½Ó×ÅʹÓÃÒÔÏÂÏÂÁî³õʼ»¯¿ÍÕ»¡£
git init
µÇ¼ºó¸´ÖÆ
´Ëʱ Git ½«ÔÚ¸ÃÎļþ¼ÐϽ¨ÉèÒ»¸ö .git µÄÒþ²ØÎļþ¼Ð£¬Õâ¸öÎļþ¼Ð½«ÓÃÓÚ´æ´¢ Git µÄÉèÖúͿÍÕ»µÄÏà¹ØÐÅÏ¢¡£
È»ºóʹÓÃÒÔÏÂÏÂÁ¿ÍÕ»Óë GitHub µÄÔ¶³Ì¿ÍÕ»¾ÙÐйØÁª¡£
git remote add origin git@github.com:username/repo.git
µÇ¼ºó¸´ÖÆ
ÆäÖÐµÄ username ºÍ repo »®·ÖÊÇÄãµÄ GitHub Õ˺źÍÏëÒª½¨ÉèµÄ¿ÍÕ»Ãû¡£¸ÃÏÂÁ½¨Éè SSH ÅþÁ¬£¬È·±£ÄãÒѾÔÚ GitHub µÄÍøÕ¾ÖÐ[Ìí¼ÓÁËÄãµÄ SSH key ](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh)¡£
µÚËIJ½£¬Ìá½»½ÓÂë
ÔÚÉÏÒ»°ì·¨ÖУ¬ÎÒÃÇÒѾÈÃÍâµØ¿ÍÕ»Óë GitHub µÄÔ¶³Ì¿ÍÕ»¾ÙÐÐÁËÅþÁ¬¡£ÏÖÔÚ£¬ÎÒÃÇÒªÏò¿ÍÕ»ÖÐÌá½»Ò»¸öеÄÎļþ¡£
ÔÚ¡°GitHub¡±Îļþ¼ÐÖн¨ÉèÒ»¸öÃûΪ¡°README.md¡±µÄÎļþ£¬²¢Ìí¼ÓһЩÄÚÈÝ¡£
ʹÓÃÒÔÏÂÏÂÁ¸ÃÎļþÌí¼Óµ½¿ÍÕ»¡£
git add README.md
µÇ¼ºó¸´ÖÆ
½Ó×ÅʹÓÃÒÔÏÂÏÂÁ¸ÃÎļþÌá½»µ½ÍâµØ¿ÍÕ»¡£
git commit -m "initial commit"
µÇ¼ºó¸´ÖÆ
ÕâÀïµÄ¡°initial commit¡±¾ÍÊÇÕâ¸öÌá½»¼Í¼µÄ˵Ã÷£¬Äã¿ÉÒÔËæÒâ¸ü¸Ä¡£
×îºóʹÓÃÒÔÏÂÏÂÁ¸ÃÎļþÍÆË͵½ GitHub µÄÔ¶³Ì¿ÍÕ»¡£
git push -u origin main
µÇ¼ºó¸´ÖÆ
ÆäÖÐµÄ main ÊÇĬÈÏ·ÖÖ§£¬ÈôÊÇÄãÐèÒªÆäËû·ÖÖ§£¬Çëƾ֤ÏÖÕæÏàÐξÙÐиü¸Ä¡£
µÚÎå²½£¬Éó²éÌá½»¼Í¼
ÔÚÉÏÒ»°ì·¨ÖУ¬ÎÒÃÇÒѾÀֳɽ«ÍâµØµÄ´úÂëÌá½»µ½ÁË GitHub ÉÏ¡£ÏÖÔÚ£¬ÎÒÃÇÒªÉó²éÌá½»¼Í¼¡£
ʹÓÃÒÔÏÂÏÂÁîÉó²éÄ¿½ñ·Ö֧ϵÄËùÓÐÌá½»¼Í¼¡£
git log
µÇ¼ºó¸´ÖÆ
¸ÃÏÂÁî»áÁгöËùÓÐÌá½»¼Í¼µÄÐÅÏ¢£¬°üÀ¨Ìá½»ÈË¡¢Ìύʱ¼ä¡¢Ìá½»¼Í¼ÐÅÏ¢µÈµÈ¡£
ÈôÊÇÄãÏëÉó²éij¸öÌá½»¼Í¼µÄÏêϸÐÅÏ¢£¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁî¡£
git show commit_id
µÇ¼ºó¸´ÖÆ
ÆäÖÐµÄ commit_id ÊǸÃÌá½»¼Í¼µÄ¹þÏ£Öµ£¬¿ÉÒÔͨ¹ý git log ÏÂÁîÉó²é¡£
µÚÁù²½£¬ÀÈ¡´úÂë
ÔÚÐ×÷¿ª·¢µÄÀú³ÌÖУ¬³ýÁËÐèÒªÍÆËÍ´úÂ룬»¹ÐèҪʵʱµØÀÈ¡ËûÈ˵ĴúÂ룬°ü¹Ü×Ô¼ºµÄÍâµØ´úÂëÓë GitHub ÉϵĴúÂë¼á³Öͬ²½¡£
ʹÓÃÒÔÏÂÏÂÁîÀÈ¡Ö÷·ÖÖ§ÉϵĴúÂë¡£
git pull origin main
µÇ¼ºó¸´ÖÆ
¸ÃÏÂÁ´ÓÔ¶³Ì¿ÍÕ»ÖÐÀÈ¡×îеĴúÂ룬²¢½«ÆäºÏ²¢µ½ÍâµØ¿ÍÕ»ÖС£
ÈôÊÇÄúÐèÒªÀÈ¡ÆäËû·ÖÖ§µÄ´úÂ룬Ç뽫 main Ì滻ΪÏÖʵÐèÒªÀÈ¡µÄ·ÖÖ§Ãû³Æ¡£
ÖÁ´Ë£¬ÎÒÃÇÒѾÀֳɵØÔÚ Mac µçÄÔÉϴÁË GitHub ÇéÐΡ£¼ÇµÃÒ»Ö±µØѧϰºÍ¸üÐÂÄãµÄ´úÂ룬ÓëËûÈËÐ×÷¿ª·¢¡£×£ÄãÔÚ GitHub Àֳɡ¢¿ìÀÖµØÂëÅ©Ö®Âã¡
ÒÔÉϾÍÊÇÏê½âmacÉÏÔõô´î½¨GitHubÇéÐεÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡