ÔõÑùʹÓÃGITÀ´Éó²é¸Ä¶¯µÄÎļþ
gitÊÇÒ»¿îºÜÊÇÇ¿Ê¢µÄ°æ±¾¿ØÖƹ¤¾ß£¬ËüÓÐן»ºñµÄ¹¦Ð§ºÍÏÂÁ¿ÉÒÔ×ÊÖú¿ª·¢Õ߸üºÃµÄÐͬÊÂÇé¡£¶øÔÚÈÕ³£¿ª·¢ÖУ¬ÎÒÃÇ¿ÉÄÜÐèÒªÉó²éÌá½»µ½¿ÍÕ»µÄ¸ü¸ÄÎļþ£¬ÒÔ¼°Ä¿½ñËù×öµÄ¸ü¸Ä¡£ÄÇô£¬±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃgitÀ´Éó²é¸Ä¶¯µÄÎļþ¡£
Ò»¡¢Éó²éÌá½»µ½¿ÍÕ»µÄ¸ü¸ÄÎļþ
µ±ÎÒÃÇÌá½»¸ü¸Äµ½¿ÍÕ»ºó£¬ÎÒÃÇ¿ÉÄܲ»ÖªµÀ´Ë´Î¸ü¸ÄÏêϸÐÞ¸ÄÁËÄÄЩÎļþ£¬ÄÇôÔõÑùÉó²éÕâЩ¸ü¸ÄµÄÎļþÄØ£¿ git diffÏÂÁîÌṩÁËÕâ¸ö¹¦Ð§¡£Ö´ÐÐÒÔÏÂÏÂÁî¼´¿ÉÉó²éÌá½»µ½¿ÍÕ»µÄ¸ü¸ÄÎļþ£º
git diff <commit> <commit></commit></commit>
µÇ¼ºó¸´ÖÆ
ÆäÖУ¬ ÊÇÖ¸Ìá½»¼Í¼µÄID¡£
ʾÀý£º
git diff c5a82a5 54d9b41
µÇ¼ºó¸´ÖÆ
Ö´ÐÐÒÔÉÏÏÂÁîºó£¬Öն˽«ÏÔʾµ±Ìõ¼þ½»µ½¿ÍÕ»ÖÐËùÓиü¸ÄµÄÎļþÒÔ¼°Ïêϸ¸ü¸ÄÄÚÈÝ¡£
¶þ¡¢Éó²éÄ¿½ñËù×öµÄ¸ü¸Ä
ÔÚ¿ª·¢Àú³ÌÖУ¬ÎÒÃÇ¿ÉÄÜÐèÒªÉó²éÄ¿½ñËùÐ޸ĵÄÎļþ£¬ÒÔ¼°ÏêϸµÄ¸ü¸ÄÄÚÈÝÒÔ±ãÎÒÃǸüºÃµÄ¾ÙÐпª·¢ÊÂÇé¡£ÄÇô£¬ÔõÑùÉó²éÄ¿½ñËù×öµÄ¸ü¸ÄÄØ£¿ÒªÉó²éÄ¿½ñËù×öµÄ¸ü¸Ä£¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ
git status
µÇ¼ºó¸´ÖÆ
Ö´ÐÐÒÔÉÏÏÂÁîºó£¬Öն˽«Ö¸³öÄ¿½ñÐ޸ĵÄÎļþÒÔ¼°×´Ì¬¡£ÈôÊÇÎļþÒÑÐ޸ĵ«Î´±»Ìá½»£¬Ôò»áÊä³öÒÔÏÂÐÅÏ¢£º
Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: <file1> modified: <file2></file2></file1></file></file>
µÇ¼ºó¸´ÖÆ
¿ÉÒÔ¿´µ½£¬Îļþ״̬Ϊ¡°modified¡±£¨ÒÑÐ޸ģ©¡£ÔÚÎļþÃûºó£¬GIT»¹½«¸æËßÄãÄãµÄÐ޸ıÈÆð×îºóÒ»´ÎÌá½»ÒѾ±»¼ÓÈëµ½ÄÄЩ·ÖÖ§ÖÐÈ¥¡£
Èý¡¢Éó²éÎļþµÄÐÞ¸ÄÀúÊ·
ÔÚ¿ª·¢Àú³ÌÖУ¬ÎÒÃÇ¿ÉÄÜÐèÒªÉó²éÒ»¸öÎļþµÄÐÞ¸ÄÀúÊ·£¬ÒÔ±ãÎÒÃǸüºÃµÄÏàʶÎļþµÄ±ä»»ÇéÐΡ£ÄÇô£¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´Éó²éÒ»¸öÎļþµÄÐÞ¸ÄÀúÊ·£º
git log <file></file>
µÇ¼ºó¸´ÖÆ
Ö´ÐÐÒÔÉÏÏÂÁîºó£¬Öն˽«Êä³ö¸ÃÎļþµÄËùÓÐÐÞ¸ÄÀúÊ·£¬°üÀ¨Ìá½»¼Í¼¡¢×÷Õß¡¢Ìύʱ¼äµÈÐÅÏ¢¡£
ËÄ¡¢Éó²éÖ¸¶¨Ìá½»µÄ¸ü¸ÄÄÚÈÝ
ÓÐʱ¼ä£¬ÎÒÃÇ¿ÉÄÜÐèÒªÉó²éij¸öÌá½»µÄÏêϸ¸ü¸ÄÄÚÈÝ£¬ÒÔ±ãÎÒÃǸüºÃµÄÃ÷È·¿ª·¢Àú³Ì¡£ÄÇô£¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´Éó²éij¸öÌá½»µÄÏêϸ¸ü¸ÄÄÚÈÝ£º
git show <commit> <file></file></commit>
µÇ¼ºó¸´ÖÆ
ʾÀý£º
git show 54d9b41 file1.txt
µÇ¼ºó¸´ÖÆ
Ö´ÐÐÒÔÉÏÏÂÁîºó£¬Öն˽«Êä³öÖ¸¶¨Ìá½»µÄËùÓиü¸ÄÄÚÈÝ¡£
×ܽá
ͨ¹ý±¾ÎĵÄÏÈÈÝ£¬ÎÒÃÇ¿ÉÒÔÖªµÀÔõÑùʹÓÃGITÉó²é¸Ä¶¯µÄÎļþ¡£GITÌṩÁ˸»ºñµÄÏÂÁîºÍ¹¦Ð§£¬Äܹ»×ÊÖú¿ª·¢Õ߸üºÃµÄ¾ÙÐа汾¿ØÖƺÍÐͬÊÂÇé¡£Òò´Ë£¬ÕÆÎÕGITµÄ»ù±¾Ó÷¨¶Ô×ðÁú¿Ê±¿ª·¢ÊÂÇéÊǺÜÊÇÓÐ×ÊÖúµÄ¡£
ÒÔÉϾÍÊÇÔõÑùʹÓÃGITÀ´Éó²é¸Ä¶¯µÄÎļþµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡