Äú¿ÉÒÔ¾èÖú£¬Ö§³ÖÎÒÃǵĹ«ÒæÊÂÒµ¡£

1Ôª 10Ôª 50Ôª





ÈÏÖ¤Â룺  ÑéÖ¤Âë,¿´²»Çå³þ?Çëµã»÷Ë¢ÐÂÑéÖ¤Âë ±ØÌî



  ÇóÖª ÎÄÕ ÎÄ¿â Lib ÊÓƵ iPerson ¿Î³Ì ÈÏÖ¤ ×Éѯ ¹¤¾ß ½²×ù Model Center   Code  
»áÔ±   
   
 
     
   
 ¶©ÔÄ
  ¾èÖú
È«Õ»±Ø±¸¡ª¡ªGit
 
À´Ô´£º¡¶Pro Git¡· ·¢²¼ÓÚ£º 2017-5-17
  2258  次浏览      19
 

Æð²½

±¾Õ½éÉÜ¿ªÊ¼Ê¹Óà Git Ç°µÄÏà¹Ø֪ʶ¡£ÎÒÃÇ»áÏÈÁ˽âһЩ°æ±¾¿ØÖƹ¤¾ßµÄÀúÊ·±³¾°£¬È»ºóÊÔ×ÅÈà Git ÔÚÄãµÄϵͳÉÏÅÜÆðÀ´£¬Ö±µ½×îºóÅäÖú㬿ÉÒÔÕý³£¿ªÊ¼¿ª·¢¹¤×÷¡£¶ÁÍê±¾Õ£¬Äã¾Í»áÃ÷°×Ϊʲô Git »áÈç´ËÁ÷ÐУ¬ÎªÊ²Ã´ÄãÓ¦¸ÃÁ¢¼´¿ªÊ¼Ê¹ÓÃËü¡££¨²é¿´GitÏê½âϵÁеÄÈ«²¿ÎÄÕ£©

1.1 ¹ØÓÚ°æ±¾¿ØÖÆ

ʲôÊÇ°æ±¾¿ØÖÆ£¿ÎÒÕæµÄÐèÒªÂ𣿰汾¿ØÖÆÊÇÒ»ÖּǼÈô¸ÉÎļþÄÚÈݱ仯£¬ÒԱ㽫À´²éÔÄÌض¨°æ±¾ÐÞ¶©Çé¿öµÄϵͳ¡£ÔÚ±¾ÊéËùչʾµÄÀý×ÓÖУ¬ÎÒÃǽö¶Ô±£´æ×ÅÈí¼þÔ´´úÂëµÄÎı¾Îļþ×÷°æ±¾¿ØÖƹÜÀí£¬µ«Êµ¼ÊÉÏ£¬Äã¿ÉÒÔ¶ÔÈκÎÀàÐ͵ÄÎļþ½øÐа汾¿ØÖÆ¡£

Èç¹ûÄãÊÇλͼÐλòÍøÒ³Éè¼Æʦ£¬¿ÉÄÜ»áÐèÒª±£´æijһ·ùͼƬ»òÒ³Ãæ²¼¾ÖÎļþµÄËùÓÐÐÞ¶©°æ±¾£¨Õâ»òÐíÊÇÄã·Ç³£¿ÊÍûÓµÓеŦÄÜ£©¡£²ÉÓð汾¿ØÖÆϵͳ £¨VCS£©ÊǸöÃ÷ÖǵÄÑ¡Ôñ¡£ÓÐÁËËüÄã¾Í¿ÉÒÔ½«Ä³¸öÎļþ»ØËݵ½Ö®Ç°µÄ״̬£¬ÉõÖÁ½«Õû¸öÏîÄ¿¶¼»ØÍ˵½¹ýȥij¸öʱ¼äµãµÄ״̬¡£Äã¿ÉÒԱȽÏÎļþµÄ±ä»¯Ï¸½Ú£¬²é³ö×î ºóÊÇË­ÐÞ¸ÄÁËÄĸöµØ·½£¬´Ó¶øµ¼Ö³öÏÖ¹ÖÒìÎÊÌ⣬ÓÖÊÇË­ÔÚºÎʱ±¨¸æÁËij¸ö¹¦ÄÜȱÏݵȵȡ£Ê¹Óð汾¿ØÖÆϵͳͨ³£»¹Òâζ×Å£¬¾ÍËãÄãÂÒÀ´Ò»Æø°ÑÕû¸öÏîÄ¿ÖеÄÎļþ¸Ä µÄ¸ÄɾµÄɾ£¬ÄãÒ²ÕÕÑù¿ÉÒÔÇáËɻָ´µ½Ô­ÏȵÄÑù×Ó¡£µ«¶îÍâÔö¼ÓµÄ¹¤×÷Á¿È´Î¢ºõÆä΢¡£

±¾µØ°æ±¾¿ØÖÆϵͳ

Ðí¶àÈËÏ°¹ßÓø´ÖÆÕû¸öÏîĿĿ¼µÄ·½Ê½À´±£´æ²»Í¬µÄ°æ±¾£¬»òÐí»¹»á¸ÄÃû¼ÓÉϱ¸·Ýʱ¼äÒÔʾÇø±ð¡£Õâô×öΨһµÄºÃ´¦¾ÍÊǼòµ¥¡£²»¹ý»µ´¦Ò²²»ÉÙ£ºÓÐʱºò»á»ìÏýËùÔڵŤ×÷Ŀ¼£¬Ò»µ©Åª´íÎļþ¶ªÁËÊý¾Ý¾Íû·¨³·Ïú»Ö¸´¡£

ΪÁ˽â¾öÕâ¸öÎÊÌ⣬ÈËÃǺܾÃÒÔÇ°¾Í¿ª·¢ÁËÐí¶àÖÖ±¾µØ°æ±¾¿ØÖÆϵͳ£¬´ó¶à¶¼ÊDzÉÓÃijÖÖ¼òµ¥µÄÊý¾Ý¿âÀ´¼Ç¼ÎļþµÄÀú´Î¸üвîÒ죨¼ûͼ 1-1£©¡£

ͼ 1-1. ±¾µØ°æ±¾¿ØÖÆϵͳ

ÆäÖÐ×îÁ÷ÐеÄÒ»ÖÖ½Ð×ö rcs£¬ÏÖ½ñÐí¶à¼ÆËã»úϵͳÉ϶¼»¹¿´µÃµ½ËüµÄ×ÙÓ°¡£ÉõÖÁÔÚÁ÷ÐÐµÄ Mac OS X ϵͳÉÏ°²×°ÁË¿ª·¢Õß¹¤¾ß°üÖ®ºó£¬Ò²¿ÉÒÔʹÓà rcs ÃüÁî¡£ËüµÄ¹¤×÷Ô­Àí»ù±¾ÉϾÍÊDZ£´æ²¢¹ÜÀíÎļþ²¹¶¡£¨patch£©¡£Îļþ²¹¶¡ÊÇÒ»ÖÖÌض¨¸ñʽµÄÎı¾Îļþ£¬¼Ç¼×ŶÔÓ¦ÎļþÐÞ¶©Ç°ºóµÄÄÚÈݱ仯¡£ËùÒÔ£¬¸ù¾Ýÿ´Î ÐÞ¶©ºóµÄ²¹¶¡£¬rcs ¿ÉÒÔͨ¹ý²»¶Ï´ò²¹¶¡£¬¼ÆËã³ö¸÷¸ö°æ±¾µÄÎļþÄÚÈÝ¡£

¼¯Öл¯µÄ°æ±¾¿ØÖÆϵͳ

½ÓÏÂÀ´ÈËÃÇÓÖÓöµ½Ò»¸öÎÊÌ⣬ÈçºÎÈÃÔÚ²»Í¬ÏµÍ³ÉϵĿª·¢ÕßЭͬ¹¤×÷£¿ÓÚÊÇ£¬¼¯Öл¯µÄ°æ±¾¿ØÖÆϵͳ£¨ Centralized Version Control Systems£¬¼ò³Æ CVCS £©Ó¦Ô˶øÉú¡£ÕâÀàϵͳ£¬ÖîÈç CVS£¬Subversion ÒÔ¼° Perforce µÈ£¬¶¼ÓÐÒ»¸öµ¥Ò»µÄ¼¯ÖйÜÀíµÄ·þÎñÆ÷£¬±£´æËùÓÐÎļþµÄÐÞ¶©°æ±¾£¬¶øЭͬ¹¤×÷µÄÈËÃǶ¼Í¨¹ý¿Í»§¶ËÁ¬µ½Õą̂·þÎñÆ÷£¬È¡³ö×îеÄÎļþ»òÕßÌá½»¸üС£¶àÄêÒÔÀ´£¬Õâ ÒѳÉΪ°æ±¾¿ØÖÆϵͳµÄ±ê×¼×ö·¨£¨¼ûͼ 1-2£©¡£

ͼ 1-2. ¼¯Öл¯µÄ°æ±¾¿ØÖÆϵͳ

ÕâÖÖ×ö·¨´øÀ´ÁËÐí¶àºÃ´¦£¬ÌرðÊÇÏà½ÏÓÚÀÏʽµÄ±¾µØ VCS À´Ëµ¡£ÏÖÔÚ£¬Ã¿¸öÈ˶¼¿ÉÒÔÔÚÒ»¶¨³Ì¶ÈÉÏ¿´µ½ÏîÄ¿ÖеÄÆäËûÈËÕýÔÚ×öЩʲô¡£¶ø¹ÜÀíÔ±Ò²¿ÉÒÔÇáËÉÕÆ¿Øÿ¸ö¿ª·¢ÕßµÄȨÏÞ£¬²¢ÇÒ¹ÜÀíÒ»¸ö CVCS ÒªÔ¶±ÈÔÚ¸÷¸ö¿Í»§¶ËÉÏά»¤±¾µØÊý¾Ý¿âÀ´µÃÇáËÉÈÝÒס£

Ê·ÖÁ½Ã棬ÓкÃÓлµ¡£Õâô×ö×îÏÔ¶øÒ×¼ûµÄȱµãÊÇÖÐÑë·þÎñÆ÷µÄµ¥µã¹ÊÕÏ¡£Èç¹ûå´»úһСʱ£¬ÄÇôÔÚÕâһСʱÄÚ£¬Ë­¶¼ÎÞ·¨Ìá½»¸üУ¬Ò²¾ÍÎÞ·¨Ð­Í¬¹¤×÷¡£Òª ÊÇÖÐÑë·þÎñÆ÷µÄ´ÅÅÌ·¢Éú¹ÊÕÏ£¬ÅöÇÉû×ö±¸·Ý£¬»òÕß±¸·Ý²»¹»¼°Ê±£¬¾Í»¹ÊÇ»áÓжªÊ§Êý¾ÝµÄ·çÏÕ¡£×µÄÇé¿öÊdz¹µ×¶ªÊ§Õû¸öÏîÄ¿µÄËùÓÐÀúÊ·¸ü¸Ä¼Ç¼£¬¶ø±»¿Í»§¶Ë ÌáÈ¡³öÀ´µÄijЩ¿ìÕÕÊý¾Ý³ýÍ⣬µ«ÕâÑùµÄ»°ÒÀÈ»ÊǸöÎÊÌ⣬Äã²»Äܱ£Ö¤ËùÓеÄÊý¾Ý¶¼ÒѾ­ÓÐÈËÊÂÏÈÍêÕûÌáÈ¡³öÀ´¹ý¡£±¾µØ°æ±¾¿ØÖÆϵͳҲ´æÔÚÀàËÆÎÊÌ⣬ֻҪÕû¸öÏî Ä¿µÄÀúÊ·¼Ç¼±»±£´æÔÚµ¥Ò»Î»Ö㬾ÍÓжªÊ§ËùÓÐÀúÊ·¸üмǼµÄ·çÏÕ¡£

·Ö²¼Ê½°æ±¾¿ØÖÆϵͳ

ÓÚÊÇ·Ö²¼Ê½°æ±¾¿ØÖÆϵͳ£¨ Distributed Version Control System£¬¼ò³Æ DVCS £©ÃæÊÀÁË¡£ÔÚÕâÀàϵͳÖУ¬Ïñ Git£¬Mercurial£¬Bazaar ÒÔ¼° Darcs µÈ£¬¿Í»§¶Ë²¢²»Ö»ÌáÈ¡×îа汾µÄÎļþ¿ìÕÕ£¬¶øÊÇ°ÑԭʼµÄ´úÂë²Ö¿âÍêÕûµØ¾µÏñÏÂÀ´¡£ÕâôһÀ´£¬ÈκÎÒ»´¦Ð­Í¬¹¤×÷ÓõķþÎñÆ÷·¢Éú¹ÊÕÏ£¬Êº󶼿ÉÒÔÓÃÈκÎÒ»¸ö¾µ Ïñ³öÀ´µÄ±¾µØ²Ö¿â»Ö¸´¡£ÒòΪÿһ´ÎµÄÌáÈ¡²Ù×÷£¬Êµ¼ÊÉ϶¼ÊÇÒ»´Î¶Ô´úÂë²Ö¿âµÄÍêÕû±¸·Ý£¨¼ûͼ 1-3£©¡£

ͼ 1-3. ·Ö²¼Ê½°æ±¾¿ØÖÆϵͳ

¸ü½øÒ»²½£¬Ðí¶àÕâÀàϵͳ¶¼¿ÉÒÔÖ¸¶¨ºÍÈô¸É²»Í¬µÄÔ¶¶Ë´úÂë²Ö¿â½øÐн»»¥¡£¼®´Ë£¬Äã¾Í¿ÉÒÔÔÚͬһ¸öÏîÄ¿ÖУ¬·Ö±ðºÍ²»Í¬¹¤×÷С×éµÄÈËÏ໥Э×÷¡£Äã¿ÉÒÔ¸ù¾ÝÐèÒªÉ趨²»Í¬µÄЭ×÷Á÷³Ì£¬±ÈÈç²ã´ÎÄ£ÐÍʽµÄ¹¤×÷Á÷£¬¶øÕâÔÚÒÔÇ°µÄ¼¯ÖÐʽϵͳÖÐÊÇÎÞ·¨ÊµÏֵġ£

1.2 Git ¼òÊ·

ͬÉú»îÖеÄÐí¶àΰ´óʼþÒ»Ñù£¬Git µ®ÉúÓÚÒ»¸ö¼«¸»·×Õù´ó¾Ù´´ÐµÄÄê´ú¡£Linux Äں˿ªÔ´ÏîÄ¿ÓÐ×ÅΪÊýÖÚ¹ãµÄ²ÎÓëÕß¡£¾ø´ó¶àÊýµÄ Linux ÄÚºËά»¤¹¤×÷¶¼»¨ÔÚÁËÌá½»²¹¶¡ºÍ±£´æ¹éµµµÄ·±ËöÊÂÎñÉÏ£¨1991£­2002Äê¼ä£©¡£µ½ 2002 Ä꣬Õû¸öÏîÄ¿×鿪ʼÆôÓ÷ֲ¼Ê½°æ±¾¿ØÖÆϵͳ BitKeeper À´¹ÜÀíºÍά»¤´úÂë¡£

µ½ÁË 2005 Ä꣬¿ª·¢ BitKeeper µÄÉÌÒµ¹«Ë¾Í¬ Linux Äں˿ªÔ´ÉçÇøµÄºÏ×÷¹Øϵ½áÊø£¬ËûÃÇÊÕ»ØÁËÃâ·ÑʹÓà BitKeeper µÄȨÁ¦¡£Õâ¾ÍÆÈʹ Linux ¿ªÔ´ÉçÇø£¨ÌرðÊÇ Linux µÄµÞÔìÕß Linus Torvalds £©²»µÃ²»ÎüÈ¡½Ìѵ£¬Ö»Óпª·¢Ò»Ì×ÊôÓÚ×Ô¼ºµÄ°æ±¾¿ØÖÆϵͳ²Å²»ÖÁÓÚÖص¸¸²ÕÞ¡£ËûÃǶÔеÄϵͳÖƶ©ÁËÈô¸ÉÄ¿±ê£º

* ËÙ¶È * ¼òµ¥µÄÉè¼Æ * ¶Ô·ÇÏßÐÔ¿ª·¢Ä£Ê½µÄÇ¿Á¦Ö§³Ö£¨ÔÊÐíÉÏǧ¸ö²¢Ðпª·¢µÄ·ÖÖ§£© * ÍêÈ«·Ö²¼Ê½ * ÓÐÄÜÁ¦¸ßЧ¹ÜÀíÀàËÆ Linux ÄÚºËÒ»ÑùµÄ³¬´ó¹æÄ£ÏîÄ¿£¨ËٶȺÍÊý¾ÝÁ¿£©

×Ôµ®ÉúÓÚ 2005 ÄêÒÔÀ´£¬Git ÈÕÕé³ÉÊìÍêÉÆ£¬Ôڸ߶ÈÒ×ÓõÄͬʱ£¬ÈÔÈ»±£Áô×ųõÆÚÉ趨µÄÄ¿±ê¡£ËüµÄËٶȷɿ죬¼«ÆäÊʺϹÜÀí´óÏîÄ¿£¬Ëü»¹ÓÐ×ÅÁîÈËÄÑÒÔÖÃÐŵķÇÏßÐÔ·ÖÖ§¹ÜÀíϵͳ£¨¼ûµÚÈýÕ£©£¬¿ÉÒÔÓ¦¸¶¸÷ÖÖ¸´ÔÓµÄÏîÄ¿¿ª·¢ÐèÇó¡£

1.3 Git »ù´¡

ÄÇô£¬¼òµ¥µØ˵£¬Git ¾¿¾¹ÊÇÔõÑùµÄÒ»¸öϵͳÄØ£¿Çë×¢Ò⣬½ÓÏÂÀ´µÄÄÚÈݷdz£ÖØÒª£¬ÈôÊÇÀí½âÁË Git µÄ˼ÏëºÍ»ù±¾¹¤×÷Ô­Àí£¬ÓÃÆðÀ´¾Í»áÖªÆäËùÒÔÈ»£¬ÓÎÈÐÓÐÓà¡£ÔÚ¿ªÊ¼Ñ§Ï° Git µÄʱºò£¬Çë²»Òª³¢Ê԰Ѹ÷ÖÖ¸ÅÄîºÍÆäËû°æ±¾¿ØÖÆϵͳ£¨ÖîÈç Subversion ºÍ Perforce µÈ£©Ïà±ÈÄ⣬·ñÔòÈÝÒ×»ìÏýÿ¸ö²Ù×÷µÄʵ¼ÊÒâÒå¡£Git ÔÚ±£´æºÍ´¦Àí¸÷ÖÖÐÅÏ¢µÄʱºò£¬ËäÈ»²Ù×÷ÆðÀ´µÄÃüÁîÐÎʽ·Ç³£Ïà½ü£¬µ«ËüÓëÆäËû°æ±¾¿ØÖÆϵͳµÄ×ö·¨ÆÄΪ²»Í¬¡£Àí½âÕâЩ²îÒ콫ÓÐÖúÓÚÄã׼ȷµØʹÓà Git ÌṩµÄ¸÷ÖÖ¹¤¾ß¡£

Ö±½Ó¼Ç¼¿ìÕÕ£¬¶ø·Ç²îÒì±È½Ï

Git ºÍÆäËû°æ±¾¿ØÖÆϵͳµÄÖ÷Òª²î±ðÔÚÓÚ£¬Git Ö»¹ØÐÄÎļþÊý¾ÝµÄÕûÌåÊÇ·ñ·¢Éú±ä»¯£¬¶ø´ó¶àÊýÆäËûϵͳÔòÖ»¹ØÐÄÎļþÄÚÈݵľßÌå²îÒì¡£ÕâÀàϵͳ £¨CVS£¬Subversion£¬Perforce£¬Bazaar µÈµÈ£©Ã¿´Î¼Ç¼ÓÐÄÄЩÎļþ×÷Á˸üУ¬ÒÔ¼°¶¼¸üÐÂÁËÄÄЩÐеÄʲôÄÚÈÝ£¬Ç뿴ͼ 1-4¡£

ͼ 1-4. ÆäËûϵͳÔÚÿ¸ö°æ±¾ÖмǼן÷¸öÎļþµÄ¾ßÌå²îÒì

Git ²¢²»±£´æÕâЩǰºó±ä»¯µÄ²îÒìÊý¾Ý¡£Êµ¼ÊÉÏ£¬Git ¸üÏñÊǰѱ仯µÄÎļþ×÷¿ìÕպ󣬼ǼÔÚÒ»¸ö΢Ð͵ÄÎļþϵͳÖС£Ã¿´ÎÌá½»¸üÐÂʱ£¬Ëü»á×ÝÀÀÒ»±éËùÓÐÎļþµÄÖ¸ÎÆÐÅÏ¢²¢¶ÔÎļþ×÷Ò»¿ìÕÕ£¬È»ºó±£´æÒ»¸öÖ¸ÏòÕâ´Î¿ìÕÕ µÄË÷Òý¡£ÎªÌá¸ßÐÔÄÜ£¬ÈôÎļþûÓб仯£¬Git ²»»áÔٴα£´æ£¬¶øÖ»¶ÔÉϴα£´æµÄ¿ìÕÕ×÷Ò»Á´½Ó¡£Git µÄ¹¤×÷·½Ê½¾ÍÏñͼ 1-5 Ëùʾ¡£

ͼ 1-5. Git ±£´æÿ´Î¸üÐÂʱµÄÎļþ¿ìÕÕ

ÕâÊÇ Git ͬÆäËûϵͳµÄÖØÒªÇø±ð¡£ËüÍêÈ«µß¸²ÁË´«Í³°æ±¾¿ØÖƵÄÌ×·£¬²¢¶Ô¸÷¸ö»·½ÚµÄʵÏÖ·½Ê½×÷ÁËеÄÉè¼Æ¡£Git ¸üÏñÊǸöСÐ͵ÄÎļþϵͳ£¬µ«Ëüͬʱ»¹ÌṩÁËÐí¶àÒÔ´ËΪ»ù´¡µÄ³¬Ç¿¹¤¾ß£¬¶ø²»Ö»ÊÇÒ»¸ö¼òµ¥µÄ VCS¡£ÉÔºóÔÚµÚÈýÕÂÌÖÂÛ Git ·ÖÖ§¹ÜÀíµÄʱºò£¬ÎÒÃÇ»áÔÙ¿´¿´ÕâÑùµÄÉè¼Æ¾¿¾¹»á´øÀ´ÄÄЩºÃ´¦¡£

½üºõËùÓвÙ×÷¶¼ÊDZ¾µØÖ´ÐÐ

ÔÚ Git Öеľø´ó¶àÊý²Ù×÷¶¼Ö»ÐèÒª·ÃÎʱ¾µØÎļþºÍ×ÊÔ´£¬²»ÓÃÁ¬Íø¡£µ«Èç¹ûÓà CVCS µÄ»°£¬²î²»¶àËùÓвÙ×÷¶¼ÐèÒªÁ¬½ÓÍøÂç¡£ÒòΪ Git ÔÚ±¾µØ´ÅÅÌÉϾͱ£´æ×ÅËùÓе±Ç°ÏîÄ¿µÄÀúÊ·¸üУ¬ËùÒÔ´¦ÀíÆðÀ´Ëٶȷɿ졣

¾Ù¸öÀý×Ó£¬Èç¹ûÒªä¯ÀÀÏîÄ¿µÄÀúÊ·¸üÐÂÕªÒª£¬Git ²»ÓÃÅܵ½ÍâÃæµÄ·þÎñÆ÷ÉÏȥȡÊý¾Ý»ØÀ´£¬¶øÖ±½Ó´Ó±¾µØÊý¾Ý¿â¶ÁÈ¡ºóչʾ¸øÄã¿´¡£ËùÒÔÈκÎʱºòÄ㶼¿ÉÒÔÂíÉÏ·­ÔÄ£¬ÎÞÐèµÈ´ý¡£Èç¹ûÏëÒª¿´µ±Ç°°æ±¾µÄÎļþºÍÒ»¸öÔ ǰµÄ°æ±¾Ö®¼äÓкβîÒ죬Git »áÈ¡³öÒ»¸öÔÂÇ°µÄ¿ìÕպ͵±Ç°Îļþ×÷Ò»´Î²îÒìÔËË㣬¶ø²»ÓÃÇëÇóÔ¶³Ì·þÎñÆ÷À´×öÕâ¼þÊ£¬»òÊÇ°ÑÀÏ°æ±¾µÄÎļþÀ­µ½±¾µØÀ´×÷±È½Ï¡£

Óà CVCS µÄ»°£¬Ã»ÓÐÍøÂç»òÕ߶Ͽª VPN Äã¾ÍÎÞ·¨×öÈκÎÊÂÇé¡£µ«Óà Git µÄ»°£¬¾ÍËãÄãÔÚ·É»ú»òÕß»ð³µÉÏ£¬¶¼¿ÉÒԷdz£Óä¿ìµØƵ·±Ìá½»¸üУ¬µÈµ½ÁËÓÐÍøÂçµÄʱºòÔÙÉÏ´«µ½Ô¶³Ì²Ö¿â¡£Í¬Ñù£¬ÔڻؼҵÄ·ÉÏ£¬²»ÓÃÁ¬½Ó VPN ÄãÒ²¿ÉÒÔ¼ÌÐø¹¤×÷¡£»»×÷ÆäËû°æ±¾¿ØÖÆϵͳ£¬Õâô×ö¼¸ºõ²»¿ÉÄÜ£¬ÒÖ»ò·Ç³£Âé·³¡£±ÈÈç Perforce£¬Èç¹û²»Á¬µ½·þÎñÆ÷£¬¼¸ºõʲô¶¼×ö²»ÁË£¨Òë×¢£ºÄ¬ÈÏÎÞ·¨·¢³öÃüÁîp4 edit file ¿ªÊ¼±à¼­Îļþ£¬ÒòΪ Perforce ÐèÒªÁªÍø֪ͨϵͳÉùÃ÷¸ÃÎļþÕýÔÚ±»Ë­ÐÞ¶©¡£µ«Êµ¼ÊÉÏÊÖ¹¤ÐÞ¸ÄÎļþȨÏÞ¿ÉÒÔÈƹýÕâ¸öÏÞÖÆ£¬Ö»ÊÇÍê³Éºó»¹ÊÇÎÞ·¨Ìá½»¸üС££©£»Èç¹ûÊÇ Subversion »ò CVS£¬ËäÈ»¿ÉÒԱ༭Îļþ£¬µ«ÎÞ·¨Ìá½»¸üУ¬ÒòΪÊý¾Ý¿âÔÚÍøÂçÉÏ¡£¿´ÉÏÈ¥ºÃÏñÕâЩ¶¼²»ÊÇʲô´óÎÊÌ⣬µ«Êµ¼ÊÌåÑé¹ýÖ®ºó£¬Äã¾Í»á¾ªÏ²µØ·¢ÏÖ£¬ÕâÆäʵÊÇ»á´øÀ´ºÜ´ó²»Í¬µÄ¡£

ʱ¿Ì±£³ÖÊý¾ÝÍêÕûÐÔ

ÔÚ±£´æµ½ Git ֮ǰ£¬ËùÓÐÊý¾Ý¶¼Òª½øÐÐÄÚÈݵÄУÑéºÍ£¨checksum£©¼ÆË㣬²¢½«´Ë½á¹û×÷ΪÊý¾ÝµÄΨһ±êʶºÍË÷Òý¡£»»¾ä»°Ëµ£¬²»¿ÉÄÜÔÚÄãÐÞ¸ÄÁËÎļþ»òĿ¼֮ºó£¬Git Ò»ÎÞËùÖª¡£ÕâÏîÌØÐÔ×÷Ϊ Git µÄÉè¼ÆÕÜѧ£¬½¨ÔÚÕûÌå¼Ü¹¹µÄ×îµ×²ã¡£ËùÒÔÈç¹ûÎļþÔÚ´«Êäʱ±äµÃ²»ÍêÕû£¬»òÕß´ÅÅÌË𻵵¼ÖÂÎļþÊý¾Ýȱʧ£¬Git ¶¼ÄÜÁ¢¼´²ì¾õ¡£

Git ʹÓà SHA-1 Ëã·¨¼ÆËãÊý¾ÝµÄУÑéºÍ£¬Í¨¹ý¶ÔÎļþµÄÄÚÈÝ»òĿ¼µÄ½á¹¹¼ÆËã³öÒ»¸ö SHA-1 ¹þÏ£Öµ£¬×÷ΪָÎÆ×Ö·û´®¡£¸Ã×Ö´®ÓÉ 40 ¸öÊ®Áù½øÖÆ×Ö·û£¨0-9 ¼° a-f£©×é³É£¬¿´ÆðÀ´¾ÍÏñÊÇ£º

24b9da6552252987aa493b52f8696cd6d3b00373

Git µÄ¹¤×÷ÍêÈ«ÒÀÀµÓÚÕâÀàÖ¸ÎÆ×Ö´®£¬ËùÒÔÄã»á¾­³£¿´µ½ÕâÑùµÄ¹þÏ£Öµ¡£Êµ¼ÊÉÏ£¬ËùÓб£´æÔÚ Git Êý¾Ý¿âÖеĶ«Î÷¶¼ÊÇÓô˹þÏ£ÖµÀ´×÷Ë÷ÒýµÄ£¬¶ø²»ÊÇ¿¿ÎļþÃû¡£

¶àÊý²Ù×÷½öÌí¼ÓÊý¾Ý

³£ÓÃµÄ Git ²Ù×÷´ó¶à½ö½öÊÇ°ÑÊý¾ÝÌí¼Óµ½Êý¾Ý¿â¡£ÒòΪÈκÎÒ»ÖÖ²»¿ÉÄæµÄ²Ù×÷£¬±ÈÈçɾ³ýÊý¾Ý£¬¶¼»áʹ»ØÍË»òÖØÏÖÀúÊ·°æ±¾±äµÃÀ§ÄÑÖØÖØ¡£ÔÚ±ðµÄ VCS ÖУ¬Èô»¹Î´Ìá½»¸üУ¬¾ÍÓпÉÄܶªÊ§»òÕß»ìÏýһЩÐ޸ĵÄÄÚÈÝ£¬µ«ÔÚ Git Àһµ©Ìá½»¿ìÕÕÖ®ºó¾ÍÍêÈ«²»Óõ£ÐĶªÊ§Êý¾Ý£¬ÌرðÊÇÑø³É¶¨ÆÚÍÆË͵½ÆäËû²Ö¿âµÄÏ°¹ßµÄ»°¡£

ÕâÖָ߿ɿ¿ÐÔÁîÎÒÃǵĿª·¢¹¤×÷°²ÐIJ»ÉÙ£¬¾¡¹ÜÈ¥×ö¸÷ÖÖÊÔÑéÐԵij¢ÊÔºÃÁË£¬ÔÙÔõÑùÒ²²»»áŪ¶ªÊý¾Ý¡£ÖÁÓÚ Git ÄÚ²¿¾¿¾¹ÊÇÈçºÎ±£´æºÍ»Ö¸´Êý¾ÝµÄ£¬ÎÒÃÇ»áÔÚµÚ¾ÅÕÂÌÖÂÛ Git ÄÚ²¿Ô­ÀíʱÔÙ×÷ÏêÊö¡£

ÎļþµÄÈýÖÖ״̬

ºÃ£¬ÏÖÔÚÇë×¢Ò⣬½ÓÏÂÀ´Òª½²µÄ¸ÅÄî·Ç³£ÖØÒª¡£¶ÔÓÚÈκÎÒ»¸öÎļþ£¬ÔÚ Git ÄÚ¶¼Ö»ÓÐÈýÖÖ״̬£ºÒÑÌá½»£¨committed£©£¬ÒÑÐ޸ģ¨modified£©ºÍÒÑÔݴ棨staged£©¡£ÒÑÌá½»±íʾ¸ÃÎļþÒѾ­±»°²È«µØ±£´æÔÚ±¾µØÊý¾Ý¿â ÖÐÁË£»ÒÑÐ޸ıíʾÐÞ¸ÄÁËij¸öÎļþ£¬µ«»¹Ã»ÓÐÌá½»±£´æ£»ÒÑÔÝ´æ±íʾ°ÑÒÑÐ޸ĵÄÎļþ·ÅÔÚÏ´ÎÌύʱҪ±£´æµÄÇåµ¥ÖС£

ÓÉ´ËÎÒÃÇ¿´µ½ Git ¹ÜÀíÏîĿʱ£¬ÎļþÁ÷תµÄÈý¸ö¹¤×÷ÇøÓò£ºGit µÄ¹¤×÷Ŀ¼£¬ÔÝ´æÇøÓò£¬ÒÔ¼°±¾µØ²Ö¿â¡£

ͼ 1-6. ¹¤×÷Ŀ¼£¬ÔÝ´æÇøÓò£¬ÒÔ¼°±¾µØ²Ö¿â

ÿ¸öÏîÄ¿¶¼ÓÐÒ»¸ö Git Ŀ¼£¨Òë×¢£ºÈç¹û git clone ³öÀ´µÄ»°£¬¾ÍÊÇÆäÖÐ .git µÄĿ¼£»Èç¹ûgit clone --bare µÄ»°£¬Ð½¨µÄĿ¼±¾Éí¾ÍÊÇ Git Ŀ¼¡££©£¬ËüÊÇ Git ÓÃÀ´±£´æÔªÊý¾ÝºÍ¶ÔÏóÊý¾Ý¿âµÄµØ·½¡£¸ÃĿ¼·Ç³£ÖØÒª£¬Ã¿´Î¿Ë¡¾µÏñ²Ö¿âµÄʱºò£¬Êµ¼Ê¿½±´µÄ¾ÍÊÇÕâ¸öĿ¼ÀïÃæµÄÊý¾Ý¡£

´ÓÏîÄ¿ÖÐÈ¡³öij¸ö°æ±¾µÄËùÓÐÎļþºÍĿ¼£¬ÓÃÒÔ¿ªÊ¼ºóÐø¹¤×÷µÄ½Ð×ö¹¤×÷Ŀ¼¡£ÕâЩÎļþʵ¼ÊÉ϶¼ÊÇ´Ó Git Ŀ¼ÖеÄѹËõ¶ÔÏóÊý¾Ý¿âÖÐÌáÈ¡³öÀ´µÄ£¬½ÓÏÂÀ´¾Í¿ÉÒÔÔÚ¹¤×÷Ŀ¼ÖжÔÕâЩÎļþ½øÐб༭¡£

ËùνµÄÔÝ´æÇøÓòÖ»²»¹ýÊǸö¼òµ¥µÄÎļþ£¬Ò»°ã¶¼·ÅÔÚ Git Ŀ¼ÖС£ÓÐʱºòÈËÃÇ»á°ÑÕâ¸öÎļþ½Ð×öË÷ÒýÎļþ£¬²»¹ý±ê׼˵·¨»¹ÊǽÐÔÝ´æÇøÓò¡£

»ù±¾µÄ Git ¹¤×÷Á÷³ÌÈçÏ£º

1. ÔÚ¹¤×÷Ŀ¼ÖÐÐÞ¸ÄijЩÎļþ¡£ 2. ¶ÔÐ޸ĺóµÄÎļþ½øÐпìÕÕ£¬È»ºó±£´æµ½ÔÝ´æÇøÓò¡£ 3. Ìá½»¸üУ¬½«±£´æÔÚÔÝ´æÇøÓòµÄÎļþ¿ìÕÕÓÀ¾Ãת´¢µ½ Git Ŀ¼ÖС£

ËùÒÔ£¬ÎÒÃÇ¿ÉÒÔ´ÓÎļþËù´¦µÄλÖÃÀ´ÅжÏ״̬£ºÈç¹ûÊÇ Git Ŀ¼Öб£´æ×ŵÄÌض¨°æ±¾Îļþ£¬¾ÍÊôÓÚÒÑÌύ״̬£»Èç¹û×÷ÁËÐ޸IJ¢ÒÑ·ÅÈëÔÝ´æÇøÓò£¬¾ÍÊôÓÚÒÑÔÝ´æ״̬£»Èç¹û×ÔÉÏ´ÎÈ¡³öºó£¬×÷ÁËÐ޸ĵ«»¹Ã»Óзŵ½ÔÝ´æÇøÓò£¬¾Í ÊÇÒÑÐÞ¸Ä״̬¡£µ½µÚ¶þÕµÄʱºò£¬ÎÒÃÇ»á½øÒ»²½Á˽âÆäÖÐϸ½Ú£¬²¢Ñ§»áÈçºÎ¸ù¾ÝÎļþ״̬ʵʩºóÐø²Ù×÷£¬ÒÔ¼°ÔõÑùÌø¹ýÔÝ´æÖ±½ÓÌá½»¡£

1.4 °²×° Git

ÊÇʱºò¶¯ÊÖ³¢ÊÔÏ Git ÁË£¬²»¹ýµÃÏÈ°²×°ºÃËü¡£ÓÐÐí¶àÖÖ°²×°·½Ê½£¬Ö÷Òª·ÖΪÁ½ÖÖ£¬Ò»ÖÖÊÇͨ¹ý±àÒëÔ´´úÂëÀ´°²×°£»ÁíÒ»ÖÖÊÇʹÓÃΪÌض¨Æ½Ì¨Ô¤±àÒëºÃµÄ°²×°°ü¡£

´ÓÔ´´úÂë°²×°

ÈôÊÇÌõ¼þÔÊÐí£¬´ÓÔ´´úÂë°²×°ÓкܶàºÃ´¦£¬ÖÁÉÙ¿ÉÒÔ°²×°×îеİ汾¡£Git µÄÿ¸ö°æ±¾¶¼ÔÚ²»¶Ï³¢ÊԸĽøÓû§ÌåÑ飬ËùÒÔÄÜͨ¹ýÔ´´úÂë×Ô¼º±àÒë°²×°×îа汾¾ÍÔٺò»¹ýÁË¡£ÓÐЩ Linux °æ±¾×Ô´øµÄ°²×°°ü¸üÐÂÆðÀ´²¢²»¼°Ê±£¬ËùÒÔ³ý·ÇÄãÔÚÓÃ×îÐ嵀 distro »òÕß backports£¬ÄÇô´ÓÔ´´úÂë°²×°Æäʵ¸ÃËãÊÇ×î¼ÑÑ¡Ôñ¡£

Git µÄ¹¤×÷ÐèÒªµ÷Óà curl£¬zlib£¬openssl£¬expat£¬libiconv µÈ¿âµÄ´úÂ룬ËùÒÔÐèÒªÏÈ°²×°ÕâЩÒÀÀµ¹¤¾ß¡£ÔÚÓÐ yum µÄϵͳÉÏ£¨±ÈÈç Fedora£©»òÕßÓÐ apt-get µÄϵͳÉÏ£¨±ÈÈç Debian Ìåϵ£©£¬¿ÉÒÔÓÃÏÂÃæµÄÃüÁî°²×°£º

$ yum install curl-devel expat-devel gettext-devel \
openssl-devel zlib-devel

$ apt-get install libcurl4-gnutls-dev libexpat1-dev gettext \
libz-dev libssl-dev

Ö®ºó£¬´ÓÏÂÃæµÄ Git ¹Ù·½Õ¾µãÏÂÔØ×îа汾Դ´úÂ룺

http://git-scm.com/download

È»ºó±àÒë²¢°²×°£º

$ tar -zxf git-1.7.2.2.tar.gz
$ cd git-1.7.2.2
$ make prefix=/usr/local all
$ sudo make prefix=/usr/local install

ÏÖÔÚÒѾ­¿ÉÒÔÓà git ÃüÁîÁË£¬Óà git °Ñ Git ÏîÄ¿²Ö¿â¿Ë¡µ½±¾µØ£¬ÒÔ±ãÈÕºóËæʱ¸üУº

$ git clone git://git.kernel.org/pub/scm/git/git.git

ÔÚ Linux ÉÏ°²×°

Èç¹ûÒªÔÚ Linux ÉÏ°²×°Ô¤±àÒëºÃµÄ Git ¶þ½øÖÆ°²×°°ü£¬¿ÉÒÔÖ±½ÓÓÃϵͳÌṩµÄ°ü¹ÜÀí¹¤¾ß¡£ÔÚ Fedora ÉÏÓà yum °²×°£º

$ yum install git-core

ÔÚ Ubuntu ÕâÀà Debian ÌåϵµÄϵͳÉÏ£¬¿ÉÒÔÓà apt-get °²×°£º

$ apt-get install git-core

ÔÚ Mac ÉÏ°²×°

ÔÚ Mac ÉÏ°²×° Git ÓÐÁ½ÖÖ·½Ê½¡£×îÈÝÒ׵ĵ±ÊôʹÓÃͼÐλ¯µÄ Git °²×°¹¤¾ß£¬½çÃæÈçͼ 1-7£¬ÏÂÔصØÖ·ÔÚ£º

http://code.google.com/p/git-osx-installer

ͼ 1-7. Git OS X °²×°¹¤¾ß

ÁíÒ»ÖÖÊÇͨ¹ý MacPorts (http://www.macports.org) °²×°¡£Èç¹ûÒѾ­×°ºÃÁË MacPorts£¬ÓÃÏÂÃæµÄÃüÁî°²×° Git£º

$ sudo port install git-core +svn +doc +bash_completion +gitweb

ÕâÖÖ·½Ê½¾Í²»ÐèÒªÔÙ×Ô¼º°²×°ÒÀÀµ¿âÁË£¬Macports »á°ïÄã¸ã¶¨ÕâЩÂ鷳ʡ£Ò»°ãÉÏÃæÁгöµÄ°²×°Ñ¡ÏîÒѾ­¹»Óã¬ÒªÊÇÄãÏëÓà Git Á¬½Ó Subversion µÄ´úÂë²Ö¿â£¬»¹¿ÉÒÔ¼ÓÉÏ +svn Ñ¡Ï¾ßÌ彫ÔÚµÚ°ËÕÂ×÷½éÉÜ¡££¨Òë×¢£º»¹ÓÐÒ»ÖÖÊÇʹÓà homebrew£¨https://github.com/mxcl/homebrew£©£ºbrew install git¡££©

ÔÚ Windows ÉÏ°²×°

ÔÚ Windows ÉÏ°²×° Git ͬÑùÇáËÉ£¬Óиö½Ð×ö msysGit µÄÏîÄ¿ÌṩÁË°²×°°ü£¬¿ÉÒÔµ½ Google Code µÄÒ³ÃæÉÏÏÂÔØ exe °²×°Îļþ²¢ÔËÐУº

http://code.google.com/p/msysgit

Íê³É°²×°Ö®ºó£¬¾Í¿ÉÒÔʹÓÃÃüÁîÐÐµÄ git ¹¤¾ß£¨ÒѾ­×Ô´øÁË ssh ¿Í»§¶Ë£©ÁË£¬ÁíÍ⻹ÓÐÒ»¸öͼÐνçÃæµÄ Git ÏîÄ¿¹ÜÀí¹¤¾ß¡£

1.5 ³õ´ÎÔËÐÐ Git Ç°µÄÅäÖÃ

Ò»°ãÔÚеÄϵͳÉÏ£¬ÎÒÃǶ¼ÐèÒªÏÈÅäÖÃÏÂ×Ô¼ºµÄ Git ¹¤×÷»·¾³¡£ÅäÖù¤×÷Ö»ÐèÒ»´Î£¬ÒÔºóÉý¼¶Ê±»¹»áÑØÓÃÏÖÔÚµÄÅäÖᣵ±È»£¬Èç¹ûÐèÒª£¬ÄãËæʱ¿ÉÒÔÓÃÏàͬµÄÃüÁîÐÞ¸ÄÒÑÓеÄÅäÖá£

Git ÌṩÁËÒ»¸ö½Ð×ö git config µÄ¹¤¾ß£¨Òë×¢£ºÊµ¼ÊÊÇ git-config ÃüÁֻ²»¹ý¿ÉÒÔͨ¹ý git ¼ÓÒ»¸öÃû×ÖÀ´ºô½Ð´ËÃüÁî¡££©£¬×¨ÃÅÓÃÀ´ÅäÖûò¶ÁÈ¡ÏàÓ¦µÄ¹¤×÷»·¾³±äÁ¿¡£¶øÕýÊÇÓÉÕâЩ»·¾³±äÁ¿£¬¾ö¶¨ÁË Git ÔÚ¸÷¸ö»·½ÚµÄ¾ßÌ幤×÷·½Ê½ºÍÐÐΪ¡£ÕâЩ±äÁ¿¿ÉÒÔ´æ·ÅÔÚÒÔÏÂÈý¸ö²»Í¬µÄµØ·½£º

¡ñ/etc/gitconfig Îļþ£ºÏµÍ³ÖжÔËùÓÐÓû§¶¼ÆÕ±éÊÊÓõÄÅäÖá£ÈôʹÓà git config ʱÓÃ--system Ñ¡Ï¶ÁдµÄ¾ÍÊÇÕâ¸öÎļþ¡£

¡ñ~/.gitconfig Îļþ£ºÓû§Ä¿Â¼ÏµÄÅäÖÃÎļþÖ»ÊÊÓÃÓÚ¸ÃÓû§¡£ÈôʹÓà git config ʱÓÃ--global Ñ¡Ï¶ÁдµÄ¾ÍÊÇÕâ¸öÎļþ¡£

¡ñµ±Ç°ÏîÄ¿µÄ git Ŀ¼ÖеÄÅäÖÃÎļþ£¨Ò²¾ÍÊǹ¤×÷Ŀ¼ÖÐµÄ .git/config Îļþ£©£ºÕâÀïµÄÅäÖýö½öÕë¶Ôµ±Ç°ÏîÄ¿ÓÐЧ¡£Ã¿Ò»¸ö¼¶±ðµÄÅäÖö¼»á¸²¸ÇÉϲãµÄÏàͬÅäÖã¬ËùÒÔ.git/config ÀïµÄÅäÖûḲ¸Ç/etc/gitconfig ÖеÄͬÃû±äÁ¿¡£

ÔÚ Windows ϵͳÉÏ£¬Git »áÕÒÑ°Óû§Ö÷Ŀ¼Ï嵀 .gitconfig Îļþ¡£Ö÷Ŀ¼¼´ $HOME ±äÁ¿Ö¸¶¨µÄĿ¼£¬Ò»°ã¶¼ÊÇC:\Documents and Settings\$USER¡£´ËÍ⣬Git »¹»á³¢ÊÔÕÒÑ°/etc/gitconfig Îļþ£¬Ö»²»¹ý¿´µ±³õ Git ×°ÔÚʲôĿ¼£¬¾ÍÒÔ´Ë×÷Ϊ¸ùĿ¼À´¶¨Î»¡£

Óû§ÐÅÏ¢

µÚÒ»¸öÒªÅäÖõÄÊÇÄã¸öÈ˵ÄÓû§Ãû³ÆºÍµç×ÓÓʼþµØÖ·¡£ÕâÁ½ÌõÅäÖúÜÖØÒª£¬Ã¿´Î Git Ìύʱ¶¼»áÒýÓÃÕâÁ½ÌõÐÅÏ¢£¬ËµÃ÷ÊÇË­Ìá½»Á˸üУ¬ËùÒÔ»áËæ¸üÐÂÄÚÈÝÒ»Æð±»ÓÀ¾ÃÄÉÈëÀúÊ·¼Ç¼£º

$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@ example.com

Èç¹ûÓÃÁË --global Ñ¡ÏÄÇô¸ü¸ÄµÄÅäÖÃÎļþ¾ÍÊÇλÓÚÄãÓû§Ö÷Ŀ¼ÏµÄÄǸö£¬ÒÔºóÄãËùÓеÄÏîÄ¿¶¼»áĬÈÏʹÓÃÕâÀïÅäÖõÄÓû§ÐÅÏ¢¡£Èç¹ûÒªÔÚij¸öÌض¨µÄÏîÄ¿ÖÐʹÓÃÆäËûÃû×Ö»òÕßµçÓÊ£¬Ö»ÒªÈ¥µô--global Ñ¡ÏîÖØÐÂÅäÖü´¿É£¬ÐµÄÉ趨±£´æÔÚµ±Ç°ÏîÄ¿µÄ.git/config ÎļþÀï¡£

Îı¾±à¼­Æ÷

½ÓÏÂÀ´ÒªÉèÖõÄÊÇĬÈÏʹÓõÄÎı¾±à¼­Æ÷¡£Git ÐèÒªÄãÊäÈëһЩ¶îÍâÏûÏ¢µÄʱºò£¬»á×Ô¶¯µ÷ÓÃÒ»¸öÍⲿÎı¾±à¼­Æ÷¸øÄãÓá£Ä¬ÈÏ»áʹÓòÙ×÷ϵͳָ¶¨µÄĬÈϱ༭Æ÷£¬Ò»°ã¿ÉÄÜ»áÊÇ Vi »òÕß Vim¡£Èç¹ûÄãÓÐÆäËûÆ«ºÃ£¬±ÈÈç Emacs µÄ»°£¬¿ÉÒÔÖØÐÂÉèÖãº

$ git config --global core.editor emacs

²îÒì·ÖÎö¹¤¾ß

»¹ÓÐÒ»¸ö±È½Ï³£ÓõÄÊÇ£¬ÔÚ½â¾öºÏ²¢³åͻʱʹÓÃÄÄÖÖ²îÒì·ÖÎö¹¤¾ß¡£±ÈÈçÒª¸ÄÓà vimdiff µÄ»°£º

$ git config --global merge.tool vimdiff

Git ¿ÉÒÔÀí½â kdiff3£¬tkdiff£¬meld£¬xxdiff£¬emerge£¬vimdiff£¬gvimdiff£¬ecmerge£¬ºÍ opendiff µÈºÏ²¢¹¤¾ßµÄÊä³öÐÅÏ¢¡£µ±È»£¬ÄãÒ²¿ÉÒÔÖ¸¶¨Ê¹ÓÃ×Ô¼º¿ª·¢µÄ¹¤¾ß£¬¾ßÌåÔõô×ö¿ÉÒÔ²ÎÔĵÚÆßÕ¡£

²é¿´ÅäÖÃÐÅÏ¢

Òª¼ì²éÒÑÓеÄÅäÖÃÐÅÏ¢£¬¿ÉÒÔʹÓà git config --list ÃüÁ

$ git config --list
user.name=Scott Chacon
user.email=schacon@ gmail.com
color.status=auto
color.branch=auto
color.interactive=auto
color.diff=auto
...

ÓÐʱºò»á¿´µ½Öظ´µÄ±äÁ¿Ãû£¬ÄǾÍ˵Ã÷ËüÃÇÀ´×Ô²»Í¬µÄÅäÖÃÎļþ£¨±ÈÈç /etc/gitconfig ºÍ ~/.gitconfig£©£¬²»¹ý×îÖÕ Git ʵ¼Ê²ÉÓõÄÊÇ×îºóÒ»¸ö¡£

Ò²¿ÉÒÔÖ±½Ó²éÔÄij¸ö»·¾³±äÁ¿µÄÉ趨£¬Ö»Òª°ÑÌض¨µÄÃû×Ö¸úÔÚºóÃæ¼´¿É£¬ÏñÕâÑù£º

$ git config user.name Scott Chacon

1.6 »ñÈ¡°ïÖú

ÏëÁ˽â Git µÄ¸÷ʽ¹¤¾ß¸ÃÔõôÓ㬿ÉÒÔÔĶÁËüÃǵÄʹÓðïÖú£¬·½·¨ÓÐÈý£º

$ git help

$ git

--help
$ man git-

±ÈÈ磬Ҫѧϰ config ÃüÁî¿ÉÒÔÔõôÓã¬ÔËÐУº


$ git help config

ÎÒÃÇËæʱ¶¼¿ÉÒÔä¯ÀÀÕâЩ°ïÖúÐÅÏ¢¶øÎÞÐèÁ¬Íø¡£²»¹ý£¬ÒªÊÇÄã¾õµÃ»¹²»¹»£¬¿ÉÒÔµ½ Frenode IRC ·þÎñÆ÷£¨irc.freenode.net£©É쵀 #git »ò #github ƵµÀÑ°ÇóËûÈË°ïÖú¡£ÕâÁ½¸öƵµÀÉÏ×ÜÓÐ×ÅÉÏ°ÙºÅÈË£¬´ó¶à¶¼ÓÐ×ŷḻµÄ git ֪ʶ£¬²¢ÇÒÀÖÓÚÖúÈË¡£

1.7 С½á

ÖÁ´Ë£¬Äã¸Ã¶Ô Git ÓÐÁ˵ã»ù±¾ÈÏʶ£¬°üÀ¨ËüºÍÒÔÇ°ÄãʹÓÃµÄ CVCS Ö®¼äµÄ²î±ð¡£ÏÖÔÚ£¬ÔÚÄãµÄϵͳÉÏÓ¦¸ÃÒѾ­×°ºÃÁË Git£¬ÉèÖÃÁË×Ô¼ºµÄÃû×ֺ͵çÓÊ¡£½ÓÏÂÀ´ÈÃÎÒÃǼÌÐøѧϰ Git µÄ»ù´¡ÖªÊ¶¡£

   
2258 ´Îä¯ÀÀ       19
Ïà¹ØÎÄÕÂ

ÿÈÕ¹¹½¨½â¾ö·½°¸
ÈçºÎÖƶ¨ÓÐЧµÄÅäÖùÜÀíÁ÷³Ì
ÅäÖùÜÀíÖ÷Òª»î¶¯¼°ÊµÏÖ·½·¨
¹¹½¨¹ÜÀíÈëÃÅ
Ïà¹ØÎĵµ

ÅäÖùÜÀíÁ÷³Ì
ÅäÖùÜÀí°×ƤÊé
CM09_CÅäÖùÜÀí±ê×¼
ʹÓÃSVN½øÐа汾¿ØÖÆ
Ïà¹Ø¿Î³Ì

ÅäÖùÜÀíʵ¼ù
ÅäÖùÜÀí·½·¨¡¢¹¤¾ßÓëÓ¦ÓÃ
¶à²ã´Î¼¯³ÉÅäÖùÜÀí
²úÆ··¢²¼¹ÜÀí