gitÔõÑùɾ³ýÎļþ¼Ð
gitÊÇÏÖ´ú¿ª·¢ÖÐ×îÊܽӴýµÄ°æ±¾¿ØÖƹ¤¾ßÖ®Ò»¡£ËüΪ´úÂëÖÎÀíºÍÍŶÓÐ×÷ÌṩÁËÐí¶à±ãµ±ºÍ¹¦Ð§£¬Ê¹µÃ¿ª·¢ÕßÄܹ»ÇáËɵØÖÎÀíºÍÐÞ¶©´úÂ롣Ȼ¶ø£¬ÓÐʱ¼äÎÒÃÇÐèҪɾ³ýijЩÎļþ»òÎļþ¼Ð. ¶øɾ³ýÎļþ¼ÐÔÚ git Öв¢²»ÊÇÒ»¼þ¼òÆÓµÄÊÂÇ飬ÐèҪʹÓÃһЩÌØÊâµÄÏÂÁî¡£
GitÖÐɾ³ýÎļþ¼ÐµÄÏÂÁî
Ҫɾ³ý git ÖеÄÎļþ¼Ð£¬¿ÉÒÔʹÓÃÈçÏÂÏÂÁ
git rm -r folder_name
µÇ¼ºó¸´ÖÆ
ÆäÖУ¬-rÑ¡ÏîÌåÏÖÒԵݹéµÄ·½·¨É¾³ýÎļþ¼Ð£¬folder_nameÌåÏÖҪɾ³ýµÄÎļþ¼ÐµÄÃû³Æ¡£Ö´ÐÐÕâ¸öÏÂÁîºó£¬ git ½«»á½«Îļþ¼Ð´ÓË÷ÒýÖÐɾ³ý£¬²¢½«Æä´ÓÊÂÇéĿ¼ÖÐɾ³ý¡£´Ëʱ£¬Ö´ÐÐgit statusÏÂÁî»áÏÔʾÎļþ¼ÐÒѱ»É¾³ý¡£
È»¶ø£¬É¾³ýÎļþ¼Ð²¢²»»á½«Æä´Ó git µÄÀúÊ·¼Í¼Öг¹µ×ɾ³ý¡£ÕâÒâζ×Å£¬ÈôÊÇÄãÔÚij¸öºóÐøµÄ°æ±¾ÖÐÐèÒª»Ö¸´¸ÃÎļþ¼Ð£¬Ò²ÊÇ¿ÉÒÔ×öµ½µÄ¡£
Òª³¹µ×ɾ³ýÎļþ¼Ð¼°ÆäËùÓÐÀúÊ·¼Í¼£¬¿ÉÒÔʹÓÃÏÂÃæµÄÏÂÁ
git filter-branch --tree-filter 'rm -rf folder_name' HEAD
µÇ¼ºó¸´ÖÆ
ÆäÖУ¬–tree-filterÑ¡Ïî¸æËß Git ¶Ôÿ¸öÌá½»£¨ÔÚHEADµ½¸ùµÄ·¾¶ÉÏ£©Ö´ÐÐÒ»¸öÏÂÁÔÚ±¾ÀýÖÐÊÇɾ³ýÎļþ¼Ð£©£¬ rm -rf folder_nameÊÇÒ»¸öµÝ¹éɾ³ýÎļþ¼ÐµÄÏÂÁî¡£
×¢ÖØ£ºÊ¹ÓÃfilter-branchÕâ¸öÏÂÁî»áÐÞ¸Ä Git µÄÀúÊ·¼Í¼£¬Òò´ËÇëÈ·±£ÈôÊÇÓÐÆäËûÈËÕýÔÚÓëÄã¹²Ïí¿ÍÕ»£¬ÔòÓ¦¸ÃÐÉ̺á£
½áÂÛ
ÔÚÐèҪɾ³ý git ÖеÄÎļþ¼Ðʱ£¬×îºÃʹÓà git rm -r folder_nameÏÂÁÕâ¿ÉÒÔÈà Git ´ÓË÷ÒýºÍÊÂÇéĿ¼ÖÐɾ³ý¸ÃÎļþ¼Ð¡£ÈôÊÇÐèÒª³¹µ×ɾ³ý¸ÃÎļþ¼Ð¼°ÆäÀúÊ·¼Í¼£¬Ôò¿ÉÒÔʹÓÃgit filter-branchÏÂÁî¡£
¹ØÓÚ³õѧÕßÀ´Ëµ£¬Git ÊÇÒ»¸öºÜÊÇÓÐÓõŤ¾ß£¬Ëü¿ÉÒÔ´ó´óÌá¸ß¿ª·¢Ð§ÂÊ¡£¿ÉÊÇҲҪעÖØ Git µÄʹÓÃϸ½Ú£¬ÒÔÃⲻСÐÄÒýÆðÎó²Ù×÷¡£
ÒÔÉϾÍÊÇgitÔõÑùɾ³ýÎļþ¼ÐµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡