{"id":19343,"date":"2024-11-19T09:23:05","date_gmt":"2024-11-19T01:23:05","guid":{"rendered":"https:\/\/fwq.ai\/blog\/19343\/"},"modified":"2024-11-19T09:23:05","modified_gmt":"2024-11-19T01:23:05","slug":"git%e6%80%8e%e4%b9%88%e5%88%a0%e9%99%a4%e5%a4%a7%e6%96%87%e4%bb%b6%ef%bc%88%e4%b8%89%e7%a7%8d%e6%96%b9%e6%b3%95%ef%bc%89","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/19343\/","title":{"rendered":"git\u600e\u4e48\u5220\u9664\u5927\u6587\u4ef6\uff08\u4e09\u79cd\u65b9\u6cd5\uff09"},"content":{"rendered":"<p>\u5bf9\u4e8e\u4f7f\u7528git\u8fdb\u884c\u7248\u672c\u7ba1\u7406\u7684\u5f00\u53d1\u8005\u6765\u8bf4\uff0c\u5220\u9664\u4e0d\u5fc5\u8981\u7684\u5927\u6587\u4ef6\u662f\u4e00\u4e2a\u5e38\u89c1\u7684\u4efb\u52a1\u3002\u8fd9\u4e9b\u5927\u6587\u4ef6\u5f80\u5f80\u4f1a\u5360\u636e\u5927\u91cf\u7684\u5b58\u50a8\u7a7a\u95f4\uff0c\u5bfc\u81f4\u4ed3\u5e93\u53d8\u5f97\u7b28\u91cd\u3002\u5982\u679c\u4e0d\u53ca\u65f6\u5904\u7406\u8fd9\u4e9b\u5927\u6587\u4ef6\uff0c\u4f1a\u4e25\u91cd\u5f71\u54cd\u4ee3\u7801\u7684\u5f00\u53d1\u548c\u90e8\u7f72\u3002<\/p>\n<p>\u90a3\u4e48\uff0c\u5982\u4f55\u5728Git\u4e2d\u5220\u9664\u5927\u6587\u4ef6\u5462\uff1f<\/p>\n<p>\u7b2c\u4e00\u79cd\u65b9\u6cd5\u662f\u4f7f\u7528\u8fc7\u6ee4\u6587\u4ef6\u3002\u53ef\u4ee5\u901a\u8fc7.gitignore\u6587\u4ef6\u6765\u5ffd\u7565\u4e00\u4e9b\u4e0d\u5fc5\u8981\u7684\u6587\u4ef6\uff0c\u4ece\u800c\u51cf\u5c11\u63d0\u4ea4\u7684\u6570\u636e\u91cf\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u5c06\u6240\u6709\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u90fd\u6dfb\u52a0\u5230.gitignore\u6587\u4ef6\u4e2d\uff0c\u8fd9\u6837\u5c31\u80fd\u591f\u5ffd\u7565\u6389\u5b83\u4eec\u3002\u4f46\u662f\uff0c\u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5df2\u7ecf\u88ab\u63d0\u4ea4\u5230\u4ed3\u5e93\u4e2d\uff0c\u90a3\u4e48\u8fd9\u6837\u7684\u65b9\u6cd5\u5c31\u65e0\u6cd5\u5b8c\u5168\u5220\u9664\u5b83\u4eec\u3002\u56e0\u6b64\uff0c\u9700\u8981\u8003\u8651\u4e0b\u9762\u4ecb\u7ecd\u7684\u53e6\u4e00\u79cd\u65b9\u6cd5\u3002<\/p>\n<p>\u7b2c\u4e8c\u79cd\u65b9\u6cd5\u662f\u4f7f\u7528Git LFS\uff08Large File Storage\uff09\u3002Git LFS\u662f\u4e00\u4e2aGit\u6269\u5c55\uff0c\u7528\u4e8e\u5b58\u50a8\u5927\u578b\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u4f8b\u5982\u56fe\u50cf\u3001\u89c6\u9891\u548c\u97f3\u9891\u6587\u4ef6\u7b49\u3002\u4f7f\u7528Git LFS\uff0c\u53ef\u4ee5\u5c06\u8fd9\u4e9b\u5927\u6587\u4ef6\u79fb\u51faGit\u4ed3\u5e93\uff0c\u4ece\u800c\u51cf\u8f7bGit\u4ed3\u5e93\u7684\u8d1f\u8377\u3002Git LFS\u5728Git\u64cd\u4f5c\u4e2d\u7684\u4f7f\u7528\u65b9\u6cd5\u4e0e\u5e38\u89c4Git\u64cd\u4f5c\u975e\u5e38\u76f8\u4f3c\uff0c\u53ea\u9700\u8981\u7a0d\u5fae\u8fdb\u884c\u4e00\u4e9b\u914d\u7f6e\u5373\u53ef\u3002\u5177\u4f53\u800c\u8a00\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5Git LFS\u6269\u5c55\uff0c\u7136\u540e\u5728\u9879\u76ee\u4e2d\u542f\u7528\u5b83\u3002\u63a5\u4e0b\u6765\uff0c\u53ef\u4ee5\u5c06\u5927\u6587\u4ef6\u63d0\u4ea4\u5230Git LFS\u5e93\u4e2d\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u50cf\u64cd\u4f5c\u666e\u901aGit\u4ed3\u5e93\u4e00\u6837\u64cd\u4f5c\u8fd9\u4e9b\u5927\u6587\u4ef6\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u6b64\u65f6\u4fee\u6539\u6587\u4ef6\u65f6\u9700\u8981\u4f7f\u7528Git LFS\u547d\u4ee4\u8fdb\u884c\u63d0\u4ea4\u548c\u63a8\u9001\u3002<\/p>\n<p>\u7b2c\u4e09\u79cd\u65b9\u6cd5\u662f\u4f7f\u7528Git Filter-branch\u3002\u5982\u679c\u5df2\u7ecf\u5c06\u5927\u6587\u4ef6\u63d0\u4ea4\u5230Git\u4ed3\u5e93\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528Git Filter-branch\u547d\u4ee4\u5220\u9664\u5b83\u4eec\u3002Git Filter-branch\u662f\u4e00\u4e2aGit\u547d\u4ee4\uff0c\u53ef\u4ee5\u91cd\u5199Git\u4ed3\u5e93\u7684\u63d0\u4ea4\u5386\u53f2\uff0c\u4ece\u800c\u5220\u9664\u7279\u5b9a\u6587\u4ef6\u6216\u6587\u4ef6\u5939\u3002\u5177\u4f53\u800c\u8a00\uff0c\u9700\u8981\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>git filter-branch --tree-filter 'rm -f path-to-file' HEAD<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5176\u4e2d\uff0c\u201cpath-to-file\u201d\u662f\u8981\u5220\u9664\u7684\u6587\u4ef6\u8def\u5f84\u3002\u6267\u884c\u4e0a\u8ff0\u547d\u4ee4\u540e\uff0cGit\u5c06\u626b\u63cf\u6574\u4e2a\u63d0\u4ea4\u5386\u53f2\uff0c\u5e76\u5220\u9664\u5305\u542b\u201cpath-to-file\u201d\u7684\u63d0\u4ea4\u3002<\/p>\n<p>\u7efc\u4e0a\u6240\u8ff0\uff0c\u5220\u9664\u4e0d\u5fc5\u8981\u7684\u5927\u6587\u4ef6\u662f\u4e00\u4e2a\u975e\u5e38\u5e38\u89c1\u7684Git\u4efb\u52a1\u3002\u53ef\u4ee5\u4f7f\u7528\u8fc7\u6ee4\u6587\u4ef6\u3001Git LFS\u548cGit Filter-branch\u7b49\u65b9\u6cd5\u6765\u5b8c\u6210\u8fd9\u4e2a\u4efb\u52a1\uff0c\u5177\u4f53\u65b9\u6cd5\u5e94\u6839\u636e\u60c5\u51b5\u9009\u62e9\u3002\u65e0\u8bba\u4f7f\u7528\u54ea\u79cd\u65b9\u6cd5\uff0c\u90fd\u9700\u8981\u786e\u4fdd\u5728\u5220\u9664\u5927\u6587\u4ef6\u4e4b\u524d\u8fdb\u884c\u5907\u4efd\uff0c\u4ee5\u9632\u6b62\u4e0d\u5fc5\u8981\u7684\u635f\u5931\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fgit\u600e\u4e48\u5220\u9664\u5927\u6587\u4ef6\uff08\u4e09\u79cd\u65b9\u6cd5\uff09\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5bf9\u4e8e\u4f7f\u7528git\u8fdb\u884c\u7248\u672c\u7ba1\u7406\u7684\u5f00\u53d1\u8005\u6765\u8bf4\uff0c\u5220\u9664\u4e0d\u5fc5\u8981\u7684\u5927\u6587\u4ef6\u662f\u4e00\u4e2a\u5e38\u89c1\u7684\u4efb\u52a1\u3002\u8fd9\u4e9b\u5927\u6587\u4ef6\u5f80\u5f80\u4f1a\u5360\u636e\u5927\u91cf\u7684\u5b58\u50a8\u7a7a\u95f4\uff0c\u5bfc\u81f4\u4ed3\u5e93\u53d8\u5f97\u7b28\u91cd\u3002\u5982\u679c\u4e0d\u53ca\u65f6\u5904\u7406\u8fd9\u4e9b\u5927\u6587\u4ef6\uff0c\u4f1a\u4e25\u91cd\u5f71\u54cd\u4ee3\u7801\u7684\u5f00\u53d1\u548c\u90e8\u7f72\u3002 \u90a3\u4e48\uff0c\u5982\u4f55\u5728Git\u4e2d\u5220\u9664\u5927\u6587\u4ef6\u5462\uff1f \u7b2c\u4e00\u79cd\u65b9\u6cd5\u662f\u4f7f\u7528\u8fc7\u6ee4\u6587\u4ef6\u3002\u53ef\u4ee5\u901a\u8fc7.gitignore\u6587\u4ef6\u6765\u5ffd\u7565\u4e00\u4e9b\u4e0d\u5fc5\u8981\u7684\u6587\u4ef6\uff0c\u4ece\u800c\u51cf\u5c11\u63d0\u4ea4\u7684\u6570\u636e\u91cf\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u5c06\u6240\u6709\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u90fd\u6dfb\u52a0\u5230.gitignore\u6587\u4ef6\u4e2d\uff0c\u8fd9\u6837\u5c31\u80fd\u591f\u5ffd\u7565\u6389\u5b83\u4eec\u3002\u4f46\u662f\uff0c\u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u5df2\u7ecf\u88ab\u63d0\u4ea4\u5230\u4ed3\u5e93\u4e2d\uff0c\u90a3\u4e48\u8fd9\u6837\u7684\u65b9\u6cd5\u5c31\u65e0\u6cd5\u5b8c\u5168\u5220\u9664\u5b83\u4eec\u3002\u56e0\u6b64\uff0c\u9700\u8981\u8003\u8651\u4e0b\u9762\u4ecb\u7ecd\u7684\u53e6\u4e00\u79cd\u65b9\u6cd5\u3002 \u7b2c\u4e8c\u79cd\u65b9\u6cd5\u662f\u4f7f\u7528Git LFS\uff08Large File Storage\uff09\u3002Git LFS\u662f\u4e00\u4e2aGit\u6269\u5c55\uff0c\u7528\u4e8e\u5b58\u50a8\u5927\u578b\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u4f8b\u5982\u56fe\u50cf\u3001\u89c6\u9891\u548c\u97f3\u9891\u6587\u4ef6\u7b49\u3002\u4f7f\u7528Git LFS\uff0c\u53ef\u4ee5\u5c06\u8fd9\u4e9b\u5927\u6587\u4ef6\u79fb\u51faGit\u4ed3\u5e93\uff0c\u4ece\u800c\u51cf\u8f7bGit\u4ed3\u5e93\u7684\u8d1f\u8377\u3002Git LFS\u5728Git\u64cd\u4f5c\u4e2d\u7684\u4f7f\u7528\u65b9\u6cd5\u4e0e\u5e38\u89c4Git\u64cd\u4f5c\u975e\u5e38\u76f8\u4f3c\uff0c\u53ea\u9700\u8981\u7a0d\u5fae\u8fdb\u884c\u4e00\u4e9b\u914d\u7f6e\u5373\u53ef\u3002\u5177\u4f53\u800c\u8a00\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5Git LFS\u6269\u5c55\uff0c\u7136\u540e\u5728\u9879\u76ee\u4e2d\u542f\u7528\u5b83\u3002\u63a5\u4e0b\u6765\uff0c\u53ef\u4ee5\u5c06\u5927\u6587\u4ef6\u63d0\u4ea4\u5230Git LFS\u5e93\u4e2d\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u50cf\u64cd\u4f5c\u666e\u901aGit\u4ed3\u5e93\u4e00\u6837\u64cd\u4f5c\u8fd9\u4e9b\u5927\u6587\u4ef6\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u6b64\u65f6\u4fee\u6539\u6587\u4ef6\u65f6\u9700\u8981\u4f7f\u7528Git LFS\u547d\u4ee4\u8fdb\u884c\u63d0\u4ea4\u548c\u63a8\u9001\u3002 \u7b2c\u4e09\u79cd\u65b9\u6cd5\u662f\u4f7f\u7528Git Filter-branch\u3002\u5982\u679c\u5df2\u7ecf\u5c06\u5927\u6587\u4ef6\u63d0\u4ea4\u5230Git\u4ed3\u5e93\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528Git Filter-branch\u547d\u4ee4\u5220\u9664\u5b83\u4eec\u3002Git Filter-branch\u662f\u4e00\u4e2aGit\u547d\u4ee4\uff0c\u53ef\u4ee5\u91cd\u5199Git\u4ed3\u5e93\u7684\u63d0\u4ea4\u5386\u53f2\uff0c\u4ece\u800c\u5220\u9664\u7279\u5b9a\u6587\u4ef6\u6216\u6587\u4ef6\u5939\u3002\u5177\u4f53\u800c\u8a00\uff0c\u9700\u8981\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a git filter-branch &#8211;tree-filter &#8216;rm -f path-to-file&#8217; HEAD \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff0c\u201cpath-to-file\u201d\u662f\u8981\u5220\u9664\u7684\u6587\u4ef6\u8def\u5f84\u3002\u6267\u884c\u4e0a\u8ff0\u547d\u4ee4\u540e\uff0cGit\u5c06\u626b\u63cf\u6574\u4e2a\u63d0\u4ea4\u5386\u53f2\uff0c\u5e76\u5220\u9664\u5305\u542b\u201cpath-to-file\u201d\u7684\u63d0\u4ea4\u3002 \u7efc\u4e0a\u6240\u8ff0\uff0c\u5220\u9664\u4e0d\u5fc5\u8981\u7684\u5927\u6587\u4ef6\u662f\u4e00\u4e2a\u975e\u5e38\u5e38\u89c1\u7684Git\u4efb\u52a1\u3002\u53ef\u4ee5\u4f7f\u7528\u8fc7\u6ee4\u6587\u4ef6\u3001Git LFS\u548cGit Filter-branch\u7b49\u65b9\u6cd5\u6765\u5b8c\u6210\u8fd9\u4e2a\u4efb\u52a1\uff0c\u5177\u4f53\u65b9\u6cd5\u5e94\u6839\u636e\u60c5\u51b5\u9009\u62e9\u3002\u65e0\u8bba\u4f7f\u7528\u54ea\u79cd\u65b9\u6cd5\uff0c\u90fd\u9700\u8981\u786e\u4fdd\u5728\u5220\u9664\u5927\u6587\u4ef6\u4e4b\u524d\u8fdb\u884c\u5907\u4efd\uff0c\u4ee5\u9632\u6b62\u4e0d\u5fc5\u8981\u7684\u635f\u5931\u3002 \u4ee5\u4e0a\u5c31\u662fgit\u600e\u4e48\u5220\u9664\u5927\u6587\u4ef6\uff08\u4e09\u79cd\u65b9\u6cd5\uff09\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-19343","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/19343","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=19343"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/19343\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=19343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=19343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=19343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}