gitÔõôÉó²écommitÐ޸ģ¿ÏÂÁî·ÖÏí
gitÊÇÒ»ÖÖ×î³£Óõİ汾¿ØÖÆϵͳ£¬ÊÇ¿ª·¢Ö°Ô±µÄ±Ø±¸¹¤¾ß¡£ÔÚgitÖУ¬Ã¿¸öÐ޸Ķ¼»á±»´æ´¢ÎªÒ»´Îcommit¡£ÔÚÕâƪÎÄÕÂÖУ¬ÎÒÃǽ«Ñ§Ï°ÔõÑùÉó²égitÖеÄcommitÐ޸ġ£
Ê×ÏÈ£¬ÈÃÎÒÃÇÏàʶһÏÂGitµÄ»ù±¾¿´·¨£º
Repository£ºGit¿ÍÕ»£¬¼´ÄãµÄÏîÄ¿Îļþ¼Ð¡£
Commit£ºGitÖеÄÐ޸ļͼ£¬°üÀ¨ÁËÐ޸ĵÄ×÷Õß¡¢ÐÎòºÍʱ¼ä´ÁµÈÐÅÏ¢¡£
Branch£ºGitÖеķÖÖ§£¬Ö÷ÒªÓÃÓÚ¿ª·¢Àú³ÌÖжԴúÂëµÄÊèÉ¢ºÍÖÎÀí¡£
Merge£º½«Ò»¸ö·ÖÖ§µÄÐ޸ĺϲ¢µ½ÁíÒ»¸ö·ÖÖ§ÖеÄÀú³Ì¡£
½ÓÏÂÀ´£¬ÎÒÃǽ«ÏÈÈݼ¸ÖÖGitÏÂÁîÀ´Éó²écommitÐ޸ģº
git log
ÏÂÁîgit log¿ÉÒÔÁгö¿ÍÕ»ÖеÄËùÓÐcommit¼Í¼£¬ÆäÖаüÀ¨Ã¿´ÎcommitµÄÐÞ¸Ä×÷Õß¡¢ÐÎòºÍʱ¼ä´ÁµÈÐÅÏ¢¡£Äã¿ÉÒÔʹÓÃÈçÏÂÏÂÁîÀ´Éó²écommit¼Í¼£º
$ git log
µÇ¼ºó¸´ÖÆ
¸ÃÏÂÁî¿ÉÒÔÁгöËùÓÐcommit¼Í¼£¬²¢´Ó×î½üµÄ¼Í¼×îÏÈ¡£ÄãÒ²¿ÉÒÔʹÓÃһЩ²ÎÊýÀ´ÏÞÖÆÏÔʾÐÅÏ¢µÄÊýÄ¿»òɸѡcommit¼Í¼¡£ÀýÈ磺
$ git log -n 5
µÇ¼ºó¸´ÖÆ
¸ÃÏÂÁֻÏÔʾ×î½üµÄ5¸öcommit¼Í¼¡£
git show
ÏÂÁîgit show¿ÉÒÔÏÔʾָ¶¨commitµÄÏêϸÐÅÏ¢£¬°üÀ¨Ð޸ĵÄÏêϸÄÚÈÝ¡£Äã¿ÉÒÔʹÓÃÈçÏÂÏÂÁîÀ´ÏÔʾijһ´ÎcommitµÄÐÅÏ¢£º
$ git show <commit-id></commit-id>
µÇ¼ºó¸´ÖÆ
ÆäÖУ¬ ÊÇÒªÉó²écommitµÄIDºÅ¡£IDºÅ¿ÉÒÔÔÚgit logÏÂÁîµÄÊä³öÖÐÕÒµ½¡£
git diff
ÏÂÁîgit diffÓÃÓÚ½ÏÁ¿Á½¸öcommitÖ®¼äµÄ²î±ð¡£Äã¿ÉÒÔʹÓÃÈçÏÂÏÂÁîÀ´½ÏÁ¿Á½¸öcommitÖ®¼äµÄ²î±ð£º
$ git diff <commit1> <commit2></commit2></commit1>
µÇ¼ºó¸´ÖÆ
ÆäÖУ¬ ºÍ ÊÇÒª½ÏÁ¿µÄÁ½¸öcommitµÄIDºÅ¡£¸ÃÏÂÁÊä³öÁ½¸öcommitÖ®¼äµÄ²î±ð¡£
git bisect
ÏÂÁîgit bisectÓÃÓÚÔÚÒ»¸ö´óµÄcommitÀúÊ·ÖпìËÙ¶¨Î»Ò»¸öÌض¨µÄcommit¡£Äã¿ÉÒÔʹÓÃÈçÏÂÏÂÁîÀ´ÔËÐÐgit bisect£º
$ git bisect start
µÇ¼ºó¸´ÖÆ
¸ÃÏÂÁ×îÏÈÒ»¸öеĶþ·ÖËÑË÷£¨¶þ·Ö²éÕÒËã·¨£©¡£ÄúÐèÒªÏñÔÚ¶þ·ÖËÑË÷ÖÐÒ»Ñù¸æËßGitÄ¿½ñ¼ì²éµÄcommitÊÇÒ»¸ö¡°»µ¡±µÄcommitÕÕ¾ÉÒ»¸ö¡°ºÃ¡±µÄcommit¡£ÀýÈ磺
$ git bisect bad $ git bisect good <commit-id></commit-id>
µÇ¼ºó¸´ÖÆ
ÆäÖУ¬ ÊÇÄãÒÔΪÊÇ¡°ºÃ¡±µÄcommitµÄIDºÅ¡£Git»á×Ô¶¯Ñ¡ÔñÄ¿½ñcommitÀúÊ·µÄÖÐÐĵ㣬²¢½«ÄúÒƶ¯µ½¸Ãµã¡£È»ºó£¬ÄãÐèÒªÊÖ¶¯²âÊÔ´úÂëÒÔÈ·¶¨Õâ¸öcommitÊÇ¡°ºÃ¡±Õվɡ°»µ¡±¡£Ã¿´Î²âÊÔºó£¬Ê¹ÓÃÈçÏÂÏÂÁîÀ´¸æËßGit£º
$ git bisect bad
µÇ¼ºó¸´ÖÆ
»ò£º
$ git bisect good
µÇ¼ºó¸´ÖÆ
Git»áƾ֤ÄúµÄ·´Ïì¼ÌÐø¾ÙÐжþ·ÖËÑË÷£¬Ö±µ½×îÖÕÕÒµ½×¼È·µÄcommit¡£
ÒÔÉÏÊǼ¸ÖÖ³£ÓõÄGitÏÂÁÓÃÓÚÉó²écommitÐ޸ġ£Ï£ÍûÕâƪÎÄÕÂÄÜ×ÊÖúÄã¸üºÃµØʹÓÃGitÀ´ÖÎÀí´úÂë°æ±¾¡£
ÒÔÉϾÍÊÇgitÔõôÉó²écommitÐ޸ģ¿ÏÂÁî·ÖÏíµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡