centosÉÏÔõôװÖÃgit£¨½Ì³Ì£©
centos git ×°Öý̳Ì
GitÊÇÒ»¸öÂþÑÜʽ°æ±¾¿ØÖÆϵͳ£¬¿ª·¢Ö°Ô±¾³£Ê¹ÓÃËüÖÎÀí´úÂë¡£ CentOsÊÇÒ»ÖÖ³£¼ûµÄLinux¿¯Ðа棬¾ßÓÐÆÕ±éµÄÓ¦ÓÃÁìÓò¡£ÔÚ±¾ÎÄÖУ¬ÎÒÃǽ«ÌÖÂÛÔõÑùÔÚCentOsϵͳÉÏ×°ÖÃGit¡£
×°ÖÃGit
ÎÒÃÇÊ×ÏÈÐèÒª¸üÐÂϵͳÈí¼þ°üºÍ´æ´¢¿â¡£Ê¹ÓÃÒÔÏÂÏÂÁî¸üÐÂϵͳ£º
sudo yum update -y
µÇ¼ºó¸´ÖÆ
È»ºó£¬Ê¹ÓÃÒÔÏÂÏÂÁî×°ÖÃGit£º
sudo yum install git -y
µÇ¼ºó¸´ÖÆ
Õâ¸öÏÂÁ×Ô¶¯×°ÖÃGit²¢ËùÓбØÐèµÄÒÀÀµ¹ØϵºÍ°ü¡£×°ÖÃÍê³Éºó£¬ÎÒÃÇ¿ÉÒÔͨ¹ýÔËÐÐÒÔÏÂÏÂÁî¼ì²éGit×°ÖÃÊÇ·ñÀֳɣº
git --version
µÇ¼ºó¸´ÖÆ
ÈôÊÇÏÔʾGit°æ±¾ºÅ£¬Ôò˵Ã÷GitÒÑ×°ÖÃÀֳɡ£
ÉèÖÃGit
×°ÖÃGitºó£¬ÎÒÃÇÐèÒªÉèÖÃGitÉèÖá£ÕâЩÉèÖöÔGitµÄʹÓúÜÊÇÖ÷Òª¡£
Ê×ÏÈ£¬ÎÒÃÇÐèÒªÉèÖÃGitʹÓõÄÓû§ÃûºÍµç×ÓÓʼþµØµã¡£ÇëʹÓÃÒÔÏÂÏÂÁÓû§ÃûºÍµç×ÓÓʼþµØµãÌí¼Óµ½GitÈ«¾ÖÉèÖÃÖУº
git config --global user.name "Your Name" git config --global user.email "youremail@domain.com"
µÇ¼ºó¸´ÖÆ
ÇëÈ·±£¸ü¸Ä¡°Your Name¡±ºÍ¡°youremail@domain.com¡±ÎªÄú×Ô¼ºµÄÃû³ÆºÍµç×ÓÓʼþµØµã¡£
½ÓÏÂÀ´£¬ÎÒÃÇÐèÒªÉèÖÃGitʹÓÃĬÈϵÄÎı¾±à¼Æ÷¡£ÎÒÃÇ¿ÉÒÔͨ¹ýÔËÐÐÒÔÏÂÏÂÁĬÈϱà¼Æ÷ÉèÖÃΪnano£º
git config --global core.editor nano
µÇ¼ºó¸´ÖÆ
Çë×¢ÖØ£¬ÈôÊÇÄúϲ»¶Ê¹ÓÃÆäËû±à¼Æ÷£¬¿ÉÒÔ½«¡°nano¡±¸ü¸ÄΪÄúϲ»¶µÄ±à¼Æ÷µÄÃû³Æ¡£
ÒÔÉÏÉèÖÃÍê³Éºó£¬×ðÁú¿Ê±GitÒѾ׼±¸Í£µ±¡£
¿Ë¡Git´æ´¢¿â
ÏÖÔÚ£¬ÎÒÃÇÒѾװÖò¢ÉèÖÃÁËGit£¬ÎÒÃÇ¿ÉÒÔʹÓÃGit½«´æ´¢¿â¿Ë¡µ½×ðÁú¿Ê±ÍâµØÅÌËã»úÉÏ¡£
ÔÚÎÒÃÇ¿Ë¡´æ´¢¿â֮ǰ£¬ÎÒÃÇÐèҪȷ±£ÎÒÃÇÒѾÉèÖÃÁËSSHÅþÁ¬µ½×ðÁú¿Ê±GitÕË»§¡£ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁî¼ì²éÊÇ·ñ±£´æSSHÃÜÔ¿£º
ls -al ~/.ssh
µÇ¼ºó¸´ÖÆ
ÈôÊǸÃĿ¼ÖÐûÓС°id_rsa¡±ºÍ¡°id_rsa.pub¡±Îļþ£¬Ôò˵Ã÷ûÓÐSSHÃÜÔ¿¡£ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁÉèеÄSSHÃÜÔ¿£º
ssh-keygen -t rsa -b 4096 -C "youremail@domain.com"
µÇ¼ºó¸´ÖÆ
Çë×¢ÖØ£¬½«¡°youremail@domain.com¡±¸ü¸ÄΪÄú×Ô¼ºµÄµç×ÓÓʼþµØµã¡£
ÔÚÌìÉúSSHÃÜÔ¿ºó£¬ÎÒÃÇÐèÒª½«¹«¹²SSHÃÜÔ¿Ìí¼Óµ½×ðÁú¿Ê±GitÕË»§ÖС£
ÏÖÔÚ£¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´¿Ë¡Git´æ´¢¿â£º
git clone git@github.com:yourusername/yourrepositoryname.git
µÇ¼ºó¸´ÖÆ
ÇëʹÓÃÄú×Ô¼ºµÄÓû§ÃûºÍ´æ´¢¿âÃû³ÆÌæ»»¡°yourusername¡±ºÍ¡°yourrepositoryname¡±¡£ÈôÊÇÄúµÄ´æ´¢¿âÊÇ˽Óеģ¬ÔòÐèÒª¾ÙÐÐÉí·ÝÑéÖ¤¡£
ʹÓÃGit¾ÙÐа汾¿ØÖÆ
ÏÖÔÚ£¬ÎÒÃÇÒѾÀֳɵØ×°Öò¢ÉèÖÃÁËGit£¬²¢¿Ë¡ÁË´æ´¢¿â¡£ÎÒÃÇ¿ÉÒÔʹÓÃGit×îÏȶԴ洢¿â¾ÙÐа汾¿ØÖÆ¡£
Ê×ÏÈ£¬ÎÒÃÇÐèÒªÒƶ¯µ½¿Ë¡µÄ´æ´¢¿âĿ¼ÖС£È»ºó£¬ÎÒÃÇÐèҪʹÓÃÒÔÏÂÏÂÁîÀ´½«ËùÓиü¸ÄÌí¼Óµ½Git»º´æÖУº
git add .
µÇ¼ºó¸´ÖÆ
Õ⽫Ìí¼ÓËùÓиü¸Ä¡£
½ÓÏÂÀ´£¬ÎÒÃÇÐèҪʹÓÃÒÔÏÂÏÂÁîÀ´Ìá½»¸ü¸Ä£º
git commit -m "Commit message"
µÇ¼ºó¸´ÖÆ
Ç뽫¡°Commit message¡±¸ü¸ÄΪÄúÏëÒªÓÃÓÚÌá½»µÄÐÅÏ¢¡£
×îºó£¬ÎÒÃÇÐèҪʹÓÃÒÔÏÂÏÂÁ¸ü¸ÄÍÆË͵½´æ´¢¿â£º
git push origin master
µÇ¼ºó¸´ÖÆ
Ç뽫¡°origin¡±¸ü¸ÄΪÄúµÄ´æ´¢¿âµÄÃû³Æ£¬²¢½«¡°master¡±¸ü¸ÄΪÄúÏëÒª½«¸ü¸ÄÍÆË͵½µÄ·ÖÖ§Ãû³Æ¡£
×ܽá
ÔÚ±¾½Ì³ÌÖУ¬ÎÒÃÇѧϰÁËÔõÑùÔÚCentOSϵͳÉÏ×°Öá¢ÉèÖúÍʹÓÃGit¡£×°ÖÃGitÊÇÒ»Ïî¼òÆÓµÄʹÃü£¬²¢ÇÒ×ñÕÕÀàËƵÄÀú³ÌÊÊÓÃÓÚÆäËûLinux¿¯Ðа档ÉèÖÃGitÊǺÜÊÇÖ÷ÒªµÄ£¬ÓÉÓÚËü½«Ó°ÏìGitµÄʹÓÃÌåÑ顣ʹÓÃGit¾ÙÐа汾¿ØÖÆ¿ÉÒÔ×ÊÖú¿ª·¢Ö°Ô±¸üºÃµØÖÎÀí´úÂë¡£
ÒÔÉϾÍÊÇcentosÉÏÔõôװÖÃgit£¨½Ì³Ì£©µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡