µ±Ç°Î»ÖÃ: > Linux·þÎñÆ÷ > Git >

2016 Git ÐÂÊÓ½ç

ʱ¼ä:2017-04-19 12:46À´Ô´:linux.it.net.cn ×÷Õß:IT

2016 Äê Git ·¢ÉúÁË ¾ªÌ춯µØ µØ±ä»¯£¬·¢²¼ÁËÎå´óÐÂÌØÐÔ¹ £¨´Ó v2.7  µ½  v2.11 £©ºÍÊ®Áù¸ö²¹¶¡²¡£189 λ×÷Õß³¹±Ï×ÁË 3676 ¸öÌá½»⁴µ½ master ·ÖÖ§£¬±È 2015 Äê¶àÁË 15%⁵£¡×ܼÆÓÐ 1545 ¸öÎļþ±»Ð޸ģ¬ÆäÖÐÔö¼ÓÁË 276799 Ðв¢ÒƳýÁË 100973 ÐÐ⁶¡£

µ«ÊÇ£¬Í¨¹ýͳ¼ÆÌá½»µÄÊýÁ¿ºÍ´úÂëÐÐÊýÀ´ºâÁ¿Éú²úÁ¦ÊÇÒ»ÖÖÊ®·ÖÓÞ´ÀµÄ·½·¨¡£³ýÁËÉî¶ÈÑо¿¹ýµÄ¿ª·¢Õß¿ÉÒÔ×öµ½Æ¾Ö±¾õÀ´ÅжϴúÂëÖÊÁ¿µÄµØ²½£¬ÎÒÃÇÆÕͨÈËÀ´×÷ÖÙ²ÃÄÑÃâ»áÒòÎÒÃdz£È˵ÄÅжÏÓÐʧƫÆÄ¡£

½÷¼ÇÕâÒ»ÌõÓÚÐÄ£¬ÎÒ¾ö¶¨ÕûÀíÕâÒ»ÄêÀïÁù¸öÎÒ×îϲ°®µÄ Git ÌØÐÔº­¸ÇµÄ¸Ä½ø£¬À´×öÒ»´Î·ÖÀà»Ø¹Ë¡£ÕâƪÎÄÕÂ×÷ΪһƪÖÐƪÍÆÎÄÓеãÌ«¹ý³¤ÁË£¬ËùÒÔÎÒ²»½éÒâÄãÃÇÖ±½ÓÌøµ½ÄãÃÇÌرð¸ÐÐËȤµÄÌØÐÔÈ¥¡£

  • Íê³É git worktree ÃüÁî
  • ¸ü¶à·½±ãµÄ git rebase Ñ¡Ïî
  • git lfs ÃλõÄÐÔÄܼÓËÙ
  • git diff ÊµÑéÐÔµÄËã·¨ºÍ¸üºÃµÄĬÈϽá¹û
  • git submodules ²îÇ¿ÈËÒâ
  • git stash µÄ90 ¸öÔöÇ¿

ÔÚÎÒÃÇ¿ªÊ¼Ö®Ç°£¬Çë×¢ÒâÔÚ´ó¶àÊý²Ù×÷ϵͳÉ϶¼×Ô´øÓÐ Git µÄ¾É°æ±¾£¬ËùÒÔÄãÐèÒª¼ì²éÄãÊÇ·ñÔÚʹÓÃ×îв¢ÇÒ×î°ôµÄ°æ±¾¡£Èç¹ûÔÚÖÕ¶ËÔËÐРgit --version ·µ»ØµÄ½á¹ûСÓÚ Git v2.11.0£¬ÇëÁ¢¿ÌÌøתµ½ Atlassian µÄ¿ìËÙÖ¸ÄÏ ¸üлò°²×° Git ²¢¸ù¾ÝÄãµÄƽ̨×ö³öÑ¡Ôñ¡£

[ËùÐèµÄ“ÒýÓÔ]

ÔÚÎÒÃǽøÈë¸ßÖÊÁ¿ÄÚÈÝ֮ǰ»¹ÐèÒª×öÒ»¸ö¶ÌÔݵÄÍ£¶Ù£ºÎÒ¾õµÃÎÒÐèҪΪÄãչʾÎÒÊÇÈçºÎ´Ó¹«¿ªÎĵµÉú³Éͳ¼ÆÐÅÏ¢£¨ÒÔ¼°¿ªÆªµÄ·âÃæͼƬ£©µÄ¡£ÄãÒ²¿ÉÒÔʹÓÃÏÂÃæµÄÃüÁîÀ´¶ÔÄã×Ô¼ºµÄ²Ö¿â×öÒ»¸ö¿ìËٵĠÄê¶È»Ø¹Ë£¡

¹ 2016 ÄêÆ¥Åä vX.Y.0 ¸ñʽµÄÀï³Ì±®


  1. $ git for-each-ref --sort=-taggerdate --format \
  2. '%(refname) %(taggerdate)' refs/tags | grep "v\d\.\d*\.0 .* 2016"

² 2016 ÄêÆ¥Åä vX.Y.Z ¸ñʽµÄÀï³Ì±®


  1. $ git for-each-ref --sort=-taggerdate --format '%(refname) %(taggerdate)' refs/tags | grep "v\d\.\d*\.[^0] .* 2016"

³ 2016 Äê×ö¹ýÌá½»µÄ¹±Ï×ÕßÊýÁ¿


  1. $ git shortlog -s -n --since=2016-01-01 --until=2017-01-01

⁴ 2016 ÄêµÄÌá½»ÊýÁ¿


  1. $ git log --oneline --since=2016-01-01 --until=2017-01-01 | wc -l

⁵ ÒÔ¼° 2015 ÄêµÄÌá½»ÊýÁ¿


  1. $ git log --oneline --since=2015-01-01 --until=2016-01-01 | wc -l

⁶  2016 ÄêÌí¼Ó¡¢É¾³ýÐÐÊý


  1. $ git diff --shortstat `git rev-list -1 --until=2016-01-01 master` \
  2. `git rev-list -1 --until=2017-01-01 master`

ÒÔÉϵÄÃüÁîÊÇÔÚ Git µÄ master ·ÖÖ§ÔËÐеģ¬ËùÒÔ²»»áÏÔʾÆäËû³öÉ«µÄ·ÖÖ§ÉÏûÓкϲ¢µÄ¹¤×÷¡£Èç¹ûÄãʹÓÃÕâЩÃüÁÇë¼ÇסÌá½»µÄÊýÁ¿ºÍ´úÂëÐÐÊý²»ÊÇÓ¦¸ÃÖµµÃÐÅÀµµÄ¶ÈÁ¿·½Ê½¡£Ç벻ҪʹÓÃËüÃÇÀ´ºâÁ¿ÄãµÄÍŶӳÉÔ±µÄ¹±Ïס£

ÏÖÔÚ£¬ÈÃÎÒÃÇ¿ªÊ¼ËµºÃµÄ»Ø¹Ë……

Íê³É Git ¹¤×÷Ê÷worktree

git worktree ÃüÁîÊ״γöÏÖÓÚ Git v2.5 £¬µ«ÊÇÔÚ 2016 ÄêÓÐÁËһЩÏÔÖøµÄÔöÇ¿¡£Á½¸öÓмÛÖµµÄÐÂÌØÐÔÔÚ v2.7 ±»ÒýÈ룺list ×ÓÃüÁºÍΪ¶þ·ÖËÑË÷Ôö¼ÓÁËÃüÁî¿Õ¼äµÄ refs¡£¶ø lock/unlock ×ÓÃüÁîÔòÊÇÔÚ v2.10 ±»ÒýÈë¡£

ʲôÊǹ¤×÷Ê÷ÄØ£¿

git worktree ÃüÁîÔÊÐíÄãͬ²½µØ¼ì³öºÍ²Ù×÷´¦ÓÚ²»Í¬Â·¾¶ÏµÄͬһ²Ö¿âµÄ¶à¸ö·ÖÖ§¡£ÀýÈ磬¼ÙÈçÄãÐèÒª×öÒ»´Î¿ìËÙµÄÐÞ¸´¹¤×÷µ«ÓÖ²»ÏëÈÅÂÒÄ㵱ǰµÄ¹¤×÷Çø£¬Äã¿ÉÒÔʹÓÃÒÔÏÂÃüÁîÔÚÒ»¸öз¾¶Ï¼ì³öÒ»¸öзÖÖ§£º


  1. $ git worktree add -b hotfix/BB-1234 ../hotfix/BB-1234
  2. Preparing ../hotfix/BB-1234 (identifier BB-1234)
  3. HEAD is now at 886e0ba Merged in bedwards/BB-13430-api-merge-pr (pull request #7822)

¹¤×÷Ê÷²»½ö½öÊÇΪ·ÖÖ§¹¤×÷¡£Äã¿ÉÒÔ¼ì³ö¶à¸öÀï³Ì±®tag×÷Ϊ²»Í¬µÄ¹¤×÷Ê÷À´²¢Ðй¹½¨»ò²âÊÔËüÃÇ¡£ÀýÈ磬ÎÒ´Ó Git v2.6 ºÍ v2.7 µÄÀï³Ì±®Öд´½¨¹¤×÷Ê÷À´¼ìÑ鲻ͬ°æ±¾ Git µÄÐÐΪÌØÕ÷¡£


  1. $ git worktree add ../git-v2.6.0 v2.6.0
  2. Preparing ../git-v2.6.0 (identifier git-v2.6.0)
  3. HEAD is now at be08dee Git 2.6
  4.  
  5. $ git worktree add ../git-v2.7.0 v2.7.0
  6. Preparing ../git-v2.7.0 (identifier git-v2.7.0)
  7. HEAD is now at 7548842 Git 2.7
  8.  
  9. $ git worktree list
  10. /Users/kannonboy/src/git 7548842 [master]
  11. /Users/kannonboy/src/git-v2.6.0 be08dee (detached HEAD)
  12. /Users/kannonboy/src/git-v2.7.0 7548842 (detached HEAD)
  13.  
  14. $ cd ../git-v2.7.0 && make

ÄãҲʹÓÃͬÑùµÄ¼¼ÊõÀ´²¢Ðй¹ÔìºÍÔËÐÐÄã×Ô¼ºÓ¦ÓóÌÐòµÄ²»Í¬°æ±¾¡£

Áгö¹¤×÷Ê÷

git worktree list ×ÓÃüÁÓÚ Git v2.7 ÒýÈ룩ÏÔʾËùÓÐÓ뵱ǰ²Ö¿âÓйصŤ×÷Ê÷¡£


  1. $ git worktree list
  2. /Users/kannonboy/src/bitbucket/bitbucket 37732bd [master]
  3. /Users/kannonboy/src/bitbucket/staging d5924bc [staging]
  4. /Users/kannonboy/src/bitbucket/hotfix-1234 37732bd [hotfix/1234]

¶þ·Ö²éÕÒ¹¤×÷Ê÷

git bisect ÊÇÒ»¸ö¼ò½àµÄ Git ÃüÁ¿ÉÒÔÈÃÎÒÃǶÔÌá½»¼Ç¼ִÐÐÒ»´Î¶þ·ÖËÑË÷¡£Í¨³£ÓÃÀ´ÕÒµ½ÄÄÒ»´ÎÌá½»ÒýÈëÁËÒ»¸öÖ¸¶¨µÄÍË»¯¡£ÀýÈ磬Èç¹ûÔÚÎҵĠmaster ·ÖÖ§×îºóµÄÌá½»ÉÏÓÐÒ»¸ö²âÊÔûÓÐͨ¹ý£¬ÎÒ¿ÉÒÔʹÓàgit bisect À´¹á´©²Ö¿âµÄÀúÊ·À´ÕÒÑ°µÚÒ»´ÎÔì³ÉÕâ¸ö´íÎóµÄÌá½»¡£


  1. $ git bisect start
  2.  
  3. # ÕÒµ½ÒÑ֪ͨ¹ý²âÊÔµÄ×îºóÌá½»
  4. # £¨ÀýÈç×îеķ¢²¼Àï³Ì±®£©
  5. $ git bisect good v2.0.0
  6.  
  7. # ÕÒµ½ÒÑÖªµÄ³öÎÊÌâµÄÌá½»
  8. # £¨ÀýÈçÔÚ `master` ÉϵÄÌáʾ£©
  9. $ git bisect bad master
  10.  
  11. # ¸æËß git bisect ÒªÔËÐеĽű¾/ÃüÁ
  12. # git bisect »áÔÚ “good” ºÍ “bad”·¶Î§ÄÚ
  13. # ÕÒµ½µ¼Ö½ű¾ÒÔ·Ç 0 ״̬Í˳öµÄ×î¾ÉµÄÌá½»
  14. $ git bisect run npm test

ÔÚºǫ́£¬bisect ʹÓà refs À´¸ú×Ù “good” Óë “bad” µÄÌá½»À´×÷Ϊ¶þ·ÖËÑË÷·¶Î§µÄÉÏϽçÏÞ¡£²»ÐÒµÄÊÇ£¬¶Ô¹¤×÷Ê÷µÄ·ÛË¿À´Ëµ£¬ÕâЩ refs ¶¼´æ´¢ÔÚÑ°³£µÄ .git/refs/bisect ÃüÃû¿Õ¼ä£¬Òâζ×Å git bisect ²Ù×÷Èç¹ûÔËÐÐÔÚ²»Í¬µÄ¹¤×÷Ê÷Ï¿ÉÄܻụÏà¸ÉÈÅ¡£

µ½ÁË v2.7 °æ±¾£¬bisect µÄ refs ÒƵ½ÁË .git/worktrees/$worktree_name/refs/bisect£¬ ËùÒÔÄã¿ÉÒÔ²¢ÐÐÔËÐÐ bisect ²Ù×÷ÓÚ¶à¸ö¹¤×÷Ê÷ÖС£

Ëø¶¨¹¤×÷Ê÷

µ±ÄãÍê³ÉÁËÒ»¿Å¹¤×÷Ê÷µÄ¹¤×÷£¬Äã¿ÉÒÔÖ±½Óɾ³ýËü£¬È»ºóͨ¹ýÔËÐРgit worktree prune µÈËü±»µ±×öÀ¬»ø×Ô¶¯»ØÊÕ¡£µ«ÊÇ£¬Èç¹ûÄãÔÚÍøÂç¹²Ïí»òÕß¿ÉÒƳýý½éÉÏ´æ´¢ÁËÒ»¿Å¹¤×÷Ê÷£¬Èç¹û¹¤×÷Ê÷Ŀ¼ÔÚɾ³ýÆڼ䲻¿É·ÃÎÊ£¬¹¤×÷Ê÷»á±»ÍêÈ«Çå³ý——²»¹ÜÄãϲ²»Ï²»¶£¡Git v2.10 ÒýÈëÁË git worktree lock ºÍ unlock ×ÓÃüÁîÀ´·ÀÖ¹ÕâÖÖÇé¿ö·¢Éú¡£


  1. # ÔÚÎÒµÄ USB ÅÌÉÏËø¶¨ git-v2.7 ¹¤×÷Ê÷
  2. $ git worktree lock /Volumes/Flash_Gordon/git-v2.7 --reason \
  3. "In case I remove my removable media"

  1. # µ±ÎÒÍê³Éʱ£¬½âËø£¨²¢É¾³ý£©¸Ã¹¤×÷Ê÷
  2. $ git worktree unlock /Volumes/Flash_Gordon/git-v2.7
  3. $ rm -rf /Volumes/Flash_Gordon/git-v2.7
  4. $ git worktree prune

--reason ±êÇ©ÔÊÐíΪδÀ´µÄÄãÁôÒ»¸ö¼ÇºÅ£¬ÃèÊöΪʲôµ±³õ¹¤×÷Ê÷±»Ëø¶¨¡£git worktree unlock ºÍ lock¶¼ÒªÇóÄãÖ¸¶¨¹¤×÷Ê÷µÄ·¾¶¡£»òÕߣ¬Äã¿ÉÒÔ cd µ½¹¤×÷Ê÷Ŀ¼ȻºóÔËÐРgit worktree lock . À´´ïµ½Í¬ÑùµÄЧ¹û¡£

¸ü¶à Git ±ä»ùrebaseÑ¡Ïî

2016 ÄêÈýÔ£¬Git v2.8 Ôö¼ÓÁËÔÚÀ­È¡¹ý³ÌÖн»»¥½øÐбä»ùµÄÃüÁî git pull --rebase=interactive ¡£¶ÔÓ¦µØ£¬ÁùÔÂ·Ý Git v2.9 ·¢²¼ÁËͨ¹ý git rebase -x ÃüÁî¶ÔÖ´Ðбä»ù²Ù×÷¶ø²»ÐèÒª½øÈë½»»¥Ä£Ê½µÄÖ§³Ö¡£

Re-ɶ£¿

ÔÚÎÒÃǼÌÐøÉîÈëÇ°£¬ÎÒ¼ÙÉè¶ÁÕßÖÐÓÐЩ²¢²»ÊǺÜÊìϤ»òÕßûÓÐÍêÈ«Ï°¹ß±ä»ùÃüÁî»òÕß½»»¥Ê½±ä»ù¡£´Ó¸ÅÄîÉÏ˵£¬ËüºÜ¼òµ¥£¬µ«ÊÇÓëºÜ¶à Git µÄÇ¿´óÌØÐÔÒ»Ñù£¬±ä»ùÉ¢·¢×ÅÌýÆðÀ´ºÜ¸´ÔÓµÄרҵÊõÓïµÄÆøÏ¢¡£ËùÒÔ£¬ÔÚÎÒÃÇÉîÈëÇ°£¬ÏÈÀ´¿ìËٵĸ´Ï°Ò»ÏÂʲôÊDZä»ùrebase¡£

±ä»ù²Ù×÷Òâζ׎«Ò»¸ö»ò¶à¸öÌá½»ÔÚÒ»¸öÖ¸¶¨·ÖÖ§ÉÏÖØд¡£git rebase ÃüÁîÊDZ»Éî¶ÈÖØÔØÁË£¬µ«ÊÇ rebase Õâ¸öÃû×ÖµÄÀ´Ô´ÊÂʵÉÏ»¹ÊÇËü¾­³£±»ÓÃÀ´¸Ä±äÒ»¸ö·ÖÖ§µÄ»ù×¼Ìá½»£¨Äã»ùÓÚ´ËÌá½»´´½¨ÁËÕâ¸ö·ÖÖ§£©¡£

´Ó¸ÅÄîÉÏ˵£¬rebase ͨ¹ý½«ÄãµÄ·ÖÖ§ÉϵÄÌá½»ÁÙʱ´æ´¢ÎªÒ»ÏµÁв¹¶¡°ü£¬½Ó׎«ÕâЩ²¹¶¡°ü°´Ë³ÐòÒÀ´Î´òÔÚÄ¿±êÌá½»Ö®ÉÏ¡£

¶Ô master ·ÖÖ§µÄÒ»¸ö¹¦ÄÜ·ÖÖ§Ö´Ðбä»ù²Ù×÷ £¨git reabse master£©ÊÇÒ»ÖÖͨ¹ý½« master ·ÖÖ§ÉÏ×îеĸıäºÏ²¢µ½¹¦ÄÜ·ÖÖ§µÄ“±£ÏÊ·¨”¡£¶ÔÓÚ³¤ÆÚ´æÔڵŦÄÜ·ÖÖ§£¬¹æÂɵıä»ù²Ù×÷Äܹ»×î´ó³Ì¶ÈµÄ¼õÉÙ¿ª·¢¹ý³ÌÖгöÏÖ³åÍ»µÄ¿ÉÄÜÐÔºÍÑÏÖØÐÔ¡£

ÓÐЩÍŶӻáÑ¡ÔñÔںϲ¢ËûÃǵĸĶ¯µ½ master Ç°Á¢¼´Ö´Ðбä»ù²Ù×÷ÒÔʵÏÖÒ»´Î¿ìËٺϲ¢ £¨git merge --ff <feature>£©¡£¶Ô master ·ÖÖ§¿ìËٺϲ¢ÄãµÄÌá½»ÊÇͨ¹ý¼òµ¥µÄ½« master ref Ö¸ÏòÄãµÄÖØд·ÖÖ§µÄ¶¥µã¶ø²»ÐèÒª´´½¨Ò»¸öºÏ²¢Ìá½»¡£

±ä»ùÊÇÈç´Ë·½±ãºÍ¹¦ÄÜÇ¿´óÒÔÖÂÓÚËüÒѾ­±»Ç¶ÈëÆäËû³£¼ûµÄ Git ÃüÁîÖУ¬ÀýÈçÀ­È¡²Ù×÷ git pull ¡£Èç¹ûÄãÔÚ±¾µØ master ·ÖÖ§ÓÐδÍÆË͵ÄÌá½»£¬ÔËÐРgit pull ÃüÁî´Ó origin À­È¡Äã¶ÓÓѵĸĶ¯»áÔì³É²»±ØÒªµÄºÏ²¢Ìá½»¡£

ÕâÓеã»ìÂÒ£¬¶øÇÒÔÚ·±Ã¦µÄÍŶӣ¬Äã»á»ñµÃ³É¶ÑµÄ²»±ØÒªµÄºÏ²¢Ìá½»¡£git pull --rebase ½«Äã±¾µØµÄÌá½»ÔÚÄã¶ÓÓѵÄÌá½»ÉÏÖ´Ðбä»ù¶ø²»²úÉúÒ»¸öºÏ²¢Ìá½»¡£

ÕâºÜÕû½à°É£¡ÉõÖÁ¸ü¿á£¬Git v2.8 ÒýÈëÁËÒ»¸öÐÂÌØÐÔ£¬ÔÊÐíÄãÔÚÀ­È¡Ê± ½»»¥µØ ±ä»ù¡£

½»»¥Ê½±ä»ù

½»»¥Ê½±ä»ùÊDZä»ù²Ù×÷µÄÒ»ÖÖ¸üÇ¿´óµÄÐÎ̬¡£ºÍ±ê×¼±ä»ù²Ù×÷ÏàËÆ£¬Ëü¿ÉÒÔÖØдÌá½»£¬µ«ËüÒ²¿ÉÒÔÏòÄãÌṩһ¸ö»ú»áÈÃÄãÄܹ»½»»¥Ê½µØÐÞ¸ÄÕâЩ½«±»ÖØÐÂÔËÓÃÔÚлù×¼ÉϵÄÌá½»¡£

µ±ÄãÔËÐРgit rebase --interactive (»ò git pull --rebase=interactive)ʱ£¬Äã»áÔÚÄãµÄÎı¾±à¼­Æ÷Öеõ½Ò»¸ö¿É¹©Ñ¡ÔñµÄÌá½»ÁбíÊÓͼ¡£


  1. $ git rebase master --interactive
  2.  
  3. pick 2fde787 ACE-1294: replaced miniamalCommit with string in test
  4. pick ed93626 ACE-1294: removed pull request service from test
  5. pick b02eb9a ACE-1294: moved fromHash, toHash and diffType to batch
  6. pick e68f710 ACE-1294: added testing data to batch email file
  7.  
  8. # Rebase f32fa9d..0ddde5f onto f32fa9d (4 commands)
  9. #
  10. # Commands:
  11. # p, pick = use commit
  12. # r, reword = use commit, but edit the commit message
  13. # e, edit = use commit, but stop for amending
  14. # s, squash = use commit, but meld into previous commit
  15. # f, fixup = like "squash", but discard this commit's log message
  16. # x, exec = run command (the rest of the line) using shell
  17. # d, drop = remove commit
  18. #
  19. # These lines can be re-ordered; they are executed from top to
  20. # bottom.
  21. #
  22. # If you remove a line here THAT COMMIT WILL BE LOST.

×¢Ò⵽ÿһÌõÌá½»ÅÔ¶¼ÓÐÒ»¸ö pick¡£ÕâÊÇ¶Ô rebase ¶øÑÔ£¬“ÕÕÔ­ÑùÁôÏÂÕâ¸öÌá½»”¡£Èç¹ûÄãÏÖÔÚ¾ÍÍ˳öÎı¾±à¼­Æ÷£¬Ëü»áÖ´ÐÐÒ»´ÎÈçÉÏÎÄËùÊöµÄÆÕͨ±ä»ù²Ù×÷¡£µ«ÊÇ£¬Èç¹ûÄ㽫 pick ¸ÄΪ edit »òÕßÆäËû rebase ÃüÁîÖеÄÒ»¸ö£¬±ä»ù²Ù×÷»áÔÊÐíÄãÔÚËü±»ÖØÐÂÔËÓÃÇ°¸Ä±äËü¡£ÓÐЧµÄ±ä»ùÃüÁîÓÐÈçϼ¸ÖÖ£º

  • reword£º±à¼­Ìá½»ÐÅÏ¢¡£
  • edit£º±à¼­Ìá½»Á˵ÄÎļþ¡£
  • squash£º½«Ìá½»Óë֮ǰµÄÌá½»£¨Í¬ÔÚÎļþÖУ©ºÏ²¢£¬²¢½«Ìá½»ÐÅϢƴ½Ó¡£
  • fixup£º½«±¾Ìá½»ÓëÉÏÒ»ÌõÌá½»ºÏ²¢£¬²¢ÇÒÖð×ÖʹÓÃÉÏÒ»ÌõÌá½»µÄÌá½»ÐÅÏ¢£¨ÕâºÜ·½±ã£¬Èç¹ûÄãΪһ¸öºÜСµÄ¸Ä¶¯´´½¨Á˵ڶþ¸öÌá½»£¬¶øËü±¾Éí¾ÍÓ¦¸ÃÊôÓÚÉÏÒ»ÌõÌá½»£¬ÀýÈ磬ÄãÍü¼ÇÔÝ´æÁËÒ»¸öÎļþ£©¡£
  • exec: ÔËÐÐÒ»ÌõÈÎÒâµÄ shell ÃüÁÎÒÃǽ«»áÔÚÏÂÒ»½Ú¿´µ½±¾ÀýÒ»´Î¼ò½àµÄʹÓó¡¾°£©¡£
  • drop: Õ⽫¶ªÆúÕâÌõÌá½»¡£

ÄãÒ²¿ÉÒÔÔÚÎļþÄÚÖØÐÂÕûÀíÌá½»£¬ÕâÑù»á¸Ä±äËüÃDZ»ÖØÐÂÓ¦ÓõÄ˳Ðò¡£µ±Äã¶Ô²»Í¬µÄÖ÷Ìâ´´½¨Á˽»´íµÄÌύʱÕâ»áºÜ˳ÊÖ£¬Äã¿ÉÒÔʹÓàsquash »òÕß fixup À´½«ÆäºÏ²¢³É·ûºÏÂß¼­µÄÔ­×ÓÌá½»¡£

µ±ÄãÉèÖÃÍêÃüÁî²¢ÇÒ±£´æÕâ¸öÎļþºó£¬Git ½«µÝ¹éÿһÌõÌá½»£¬ÔÚÿ¸ö reword ºÍ edit ÃüÁΪÄãÔÝÍ£À´Ö´ÐÐÄãÉè¼ÆºÃµÄ¸Ä±ä£¬²¢ÇÒ×Ô¶¯ÔËÐРsquash£¬ fixup£¬exec ºÍ drop ÃüÁî¡£

·Ç½»»¥ÐÔʽִÐÐ

µ±ÄãÖ´Ðбä»ù²Ù×÷ʱ£¬±¾ÖÊÉÏÄãÊÇÔÚͨ¹ý½«ÄãÿһÌõÐÂÌá½»Ó¦ÓÃÓÚÖ¸¶¨»ùÖ·µÄÍ·²¿À´ÖØдÀúÊ·¡£git pull --rebase ¿ÉÄÜ»áÓÐÒ»µãΣÏÕ£¬ÒòΪ¸ù¾ÝÉÏÓηÖÖ§¸Ä¶¯µÄÊÂʵ£¬ÄãµÄн¨ÀúÊ·¿ÉÄÜ»áÓÉÓÚÌض¨µÄÌá½»ÔâÓö²âÊÔʧ°ÜÉõÖÁ±àÒëÎÊÌâ¡£Èç¹ûÕâЩ¸Ä¶¯ÒýÆðÁ˺ϲ¢³åÍ»£¬±ä»ù¹ý³Ì½«»áÔÝÍ£²¢ÇÒÔÊÐíÄãÀ´½â¾öËüÃÇ¡£µ«ÊÇ£¬Õû½àµÄºÏ²¢¸Ä¶¯ÈÔÈ»ÓпÉÄÜ´ò¶Ï±àÒë»ò²âÊÔ¹ý³Ì£¬ÁôÏÂÆưܵÄÌύŪÂÒÄãµÄÌá½»ÀúÊ·¡£

µ«ÊÇ£¬Äã¿ÉÒÔÖ¸µ¼ Git Ϊÿһ¸öÖØдµÄÌá½»À´ÔËÐÐÄãµÄÏîÄ¿²âÊÔÌ×¼þ¡£ÔÚ Git v2.9 ֮ǰ£¬Äã¿ÉÒÔͨ¹ý°ó¶¨ git rebase --interactive ºÍ exec ÃüÁîÀ´ÊµÏÖ¡£ÀýÈçÕâÑù£º


  1. $ git rebase master −−interactive −−exec=”npm test”

……Õâ»áÉú³ÉÒ»¸ö½»»¥Ê½±ä»ù¼Æ»®£¬ÔÚÖØдÿÌõÌá½»ºóÖ´ÐРnpm test £¬±£Ö¤ÄãµÄ²âÊÔÈÔÈ»»áͨ¹ý£º


  1. pick 2fde787 ACE-1294: replaced miniamalCommit with string in test
  2. exec npm test
  3. pick ed93626 ACE-1294: removed pull request service from test
  4. exec npm test
  5. pick b02eb9a ACE-1294: moved fromHash, toHash and diffType to batch
  6. exec npm test
  7. pick e68f710 ACE-1294: added testing data to batch email file
  8. exec npm test
  9.  
  10. # Rebase f32fa9d..0ddde5f onto f32fa9d (4 command(s))

Èç¹û³öÏÖÁ˲âÊÔʧ°ÜµÄÇé¿ö£¬±ä»ù»áÔÝÍ£²¢ÈÃÄãÐÞ¸´ÕâЩ²âÊÔ(²¢ÇÒ½«ÄãµÄÐÞ¸ÄÓ¦ÓÃÓÚÏàÓ¦Ìá½»)£º


  1. 291 passing
  2. 1 failing
  3.  
  4. 1) Host request "after all" hook:
  5. Uncaught Error: connect ECONNRESET 127.0.0.1:3001
  6. npm ERR! Test failed.
  7. Execution failed: npm test
  8. You can fix the problem, and then run
  9. git rebase −−continue

ÕâºÜ·½±ã£¬µ«ÊÇʹÓý»»¥Ê½±ä»ùÓÐÒ»µãÓ·Öס£µ½ÁË Git v2.9£¬Äã¿ÉÒÔÕâÑùÀ´ÊµÏַǽ»»¥Ê½±ä»ù£º


  1. $ git rebase master -x "npm test"

¿ÉÒÔ¼òµ¥Ìæ»» npm test Îª make£¬rake£¬mvn clean install£¬»òÕßÈκÎÄãÓÃÀ´¹¹½¨»ò²âÊÔÄãµÄÏîÄ¿µÄÃüÁî¡£

СС¾¯¸æ

¾ÍÏñµçÓ°ÀïÒ»Ñù£¬ÖØдÀúÊ·¿ÉÊÇÒ»¸öΣÏÕµÄÐе±¡£ÈκÎÌá½»±»ÖØдΪ±ä»ù²Ù×÷µÄÒ»²¿·Ö¶¼½«¸Ä±äËüµÄ SHA-1 ID£¬ÕâÒâζ×Å Git »á°ÑËüµ±×÷Ò»¸öȫеÄÌá½»¶Ô´ý¡£Èç¹ûÖØдµÄÀúÊ·ºÍÔ­À´µÄÀúÊ·»ìÔÓ£¬Ä㽫»ñµÃÖظ´µÄÌá½»£¬¶øÕâ¿ÉÄÜÔÚÄãµÄÍŶÓÖÐÒýÆð²»ÉÙµÄÒÉ»ó¡£

ΪÁ˱ÜÃâÕâ¸öÎÊÌ⣬Äã½ö½öÐèÒª×ñÕÕÒ»Ìõ¼òµ¥µÄ¹æÔò£º

ÓÀÔ¶²»Òª±ä»ùÒ»ÌõÄãÒѾ­ÍÆË͵ÄÌá½»£¡

¼á³ÖÕâÒ»µãÄã»áûʵġ£


(ÔðÈα༭£ºIT)

------·Ö¸ôÏß----------------------------