{"id":12749,"date":"2023-09-20T13:33:40","date_gmt":"2023-09-20T05:33:40","guid":{"rendered":"https:\/\/92it.top\/?p=12749"},"modified":"2023-09-20T13:35:44","modified_gmt":"2023-09-20T05:35:44","slug":"git%e4%b8%ad-windows%e4%b8%8elinux%e8%a1%8c%e5%b0%be%e6%8d%a2%e8%a1%8c%e7%ac%a6","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=12749","title":{"rendered":"Git\u4e2d Windows\u4e0eLinux\u884c\u5c3e\u6362\u884c\u7b26"},"content":{"rendered":"\n<p><strong>\u524d\u8a00<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u6700\u8fd1\u5728\u4f7f\u7528 Git \u63d0\u4ea4\u4ee3\u7801\u7684\u65f6\u5019\uff0c\u8001\u662f\u78b0\u5230\u4e00\u6bb5\u770b\u8d77\u6765 \u201c\u6ca1\u6709\u4efb\u4f55\u6539\u52a8\u201d \u7684\u4ee3\u7801\uff0c\u88ab diff \u68c0\u6d4b\u51fa\u5f02\u5e38\uff0c\u5f88\u662f\u82e6\u607c\uff0c\u7279\u522b\u662f\u9879\u76ee\u7d27\u6025\u7684\u65f6\u5019\uff0c\u4e0d\u6562\u7528 VSCode \u7f16\u8f91\u4e86\uff0c\u53ea\u80fd\u7528 vim \u8fdb\u884c\u5c11\u91cf\u4ee3\u7801\u7684\u4fee\u6539\u3001\u4e0a\u5e93\u3002<\/p>\n\n\n\n<p>\u53e6\u4e00\u4ef6\u4e8b\u662f shell \u811a\u672c\u6587\u4ef6\u884c\u5c3e\u6362\u884c\u7b26\u5f02\u5e38\uff0c\u5bfc\u81f4\u5728 linux \u73af\u5883\u4e0b\u65e0\u6cd5\u6b63\u5e38\u8fd0\u884c\uff0c\u603b\u662f\u63d0\u793a\u4ec0\u4e48\u8bed\u6cd5\u9519\u8bef\u3002<\/p>\n\n\n\n<p>\u6362\u4e86\u53f0\u7535\u8111\uff0cgit\u62c9\u53d6\u4ee3\u7801\u4e4b\u540e\u4f20\u5230linux\u8bbe\u5907\u4e0a\uff0c\u7136\u540egit status\u53d1\u73b0\u6240\u6709\u6587\u4ef6\u90fd\u88ab\u4fee\u6539\u4e86\uff0c\u4ed4\u7ec6\u4e00\u770b\u662f\u6bcf\u884c\u6700\u540e\u90fd\u591a\u4e86\u4e00\u4e2a__^M__\u3002<\/p>\n\n\n\n<p>Git \u7684\u591a\u5e73\u53f0\u6362\u884c\u7b26\u95ee\u9898(LF or CRLF)<\/p>\n\n\n\n<p>Windows\u4e0b\u6587\u672c\u6587\u4ef6\u6240\u4f7f\u7528\u7684\u6362\u884c\u7b26\u662fCRLF\uff0c\u800cLinux\/UNIX\/macOS\u7528\u7684\u662fLF\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u4f7f\u7528 VSCode \uff0c\u53ef\u4ee5\u901a\u8fc7\u53f3\u4e0b\u89d2\u786e\u8ba4\u5f53\u524d\u6587\u4ef6\u884c\u5c3e\u6362\u884c\u7b26\u683c\u5f0f<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-26-1024x180.png\" alt=\"\" class=\"wp-image-12750\" width=\"565\" height=\"99\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-26-1024x180.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-26-300x53.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-26-768x135.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-26-1536x270.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-26-830x146.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-26-230x40.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-26-350x62.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-26-480x84.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-26.png 1592w\" sizes=\"(max-width: 565px) 100vw, 565px\" \/><\/figure><\/div>\n\n\n\n<p><strong>\u6362\u884c\u7b26<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u5173\u4e8e\u201c\u56de\u8f66\u201d\uff08carriage return\uff09\u548c\u201c\u6362\u884c\u201d\uff08line feed\uff09\u8fd9\u4e24\u4e2a\u6982\u5ff5\u7684\u6765\u5386\u548c\u533a\u522b\u3002\u5728\u8ba1\u7b97\u673a\u8fd8\u6ca1\u6709\u51fa\u73b0\u4e4b\u524d\uff0c\u6709\u4e00\u79cd\u53eb\u505a\u7535\u4f20\u6253\u5b57\u673a\uff08Teletype Model 33\uff09\u7684\u73a9\u610f\uff0c\u6bcf\u79d2\u949f\u53ef\u4ee5\u625310\u4e2a\u5b57\u7b26\u3002\u4f46\u662f\u5b83\u6709\u4e00\u4e2a\u95ee\u9898\uff0c\u5c31\u662f\u6253\u5b8c\u4e00\u884c\u6362\u884c\u7684\u65f6\u5019\uff0c\u8981\u7528\u53bb0.2\u79d2\uff0c\u6b63\u597d\u53ef\u4ee5\u6253\u4e24\u4e2a\u5b57\u7b26\u3002\u8981\u662f\u5728\u8fd90.2\u79d2\u91cc\u9762\uff0c\u53c8\u6709\u65b0\u7684\u5b57\u7b26\u4f20\u8fc7\u6765\uff0c\u90a3\u4e48\u8fd9\u4e2a\u5b57\u7b26\u5c06\u4e22\u5931\u3002<\/p>\n\n\n\n<p>\u4e8e\u662f\uff0c\u7814\u5236\u4eba\u5458\u60f3\u4e86\u4e2a\u529e\u6cd5\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u5c31\u662f\u5728\u6bcf\u884c\u540e\u9762\u52a0\u4e24\u4e2a\u8868\u793a\u7ed3\u675f\u7684\u5b57\u7b26\u3002\u4e00\u4e2a\u53eb\u505a\u201c\u56de\u8f66\u201d\uff0c\u544a\u8bc9\u6253\u5b57\u673a\u628a\u6253\u5370\u5934\u5b9a\u4f4d\u5728\u5de6\u8fb9\u754c\uff1b\u53e6\u4e00\u4e2a\u53eb\u505a\u201c\u6362\u884c\u201d\uff0c\u544a\u8bc9\u6253\u5b57\u673a\u628a\u7eb8\u5411\u4e0b\u79fb\u4e00\u884c\u3002<\/p>\n\n\n\n<p>\u540e\u6765\uff0c\u8ba1\u7b97\u673a\u53d1\u660e\u4e86\uff0c\u8fd9\u4e24\u4e2a\u6982\u5ff5\u4e5f\u5c31\u88ab\u822c\u5230\u4e86\u8ba1\u7b97\u673a\u4e0a\u3002\u90a3\u65f6\uff0c\u5b58\u50a8\u5668\u5f88\u8d35\uff0c\u4e00\u4e9b\u79d1\u5b66\u5bb6\u8ba4\u4e3a\u5728\u6bcf\u884c\u7ed3\u5c3e\u52a0\u4e24\u4e2a\u5b57\u7b26\u592a\u6d6a\u8d39\u4e86\uff0c\u52a0\u4e00\u4e2a\u5c31\u53ef\u4ee5\u3002\u4e8e\u662f\uff0c\u5c31\u51fa\u73b0\u4e86\u5206\u6b67\u3002Unix\u7cfb\u7edf\u91cc\uff0c\u6bcf\u884c\u7ed3\u5c3e\u53ea\u6709\u201c&lt;\u6362\u884c&gt;\u201d\uff0c\u5373\u201c\\n\u201d\uff1bWindows\u7cfb\u7edf\u91cc\u9762\uff0c\u6bcf\u884c\u7ed3\u5c3e\u662f\u201c &lt;\u56de\u8f66&gt;&lt;\u6362\u884c&gt;\u201d\uff0c\u5373\u201c\\r\\n\u201d\uff1bMac\u7cfb\u7edf\u91cc\uff0c\u6bcf\u884c\u7ed3\u5c3e\u662f\u201c&lt;\u56de\u8f66&gt;\u201d\u3002\u4e00\u4e2a\u76f4\u63a5\u540e\u679c\u662f\uff0cUnix\/Mac\u7cfb\u7edf\u4e0b\u7684\u6587\u4ef6\u5728Windows\u91cc\u6253\u5f00\u7684\u8bdd\uff0c\u6240\u6709\u6587\u5b57\u4f1a\u53d8\u6210\u4e00\u884c\uff1b\u800cWindows\u91cc\u7684\u6587\u4ef6\u5728Unix\/Mac\u4e0b\u6253\u5f00\u7684\u8bdd\uff0c\u5728\u6bcf\u884c\u7684\u7ed3\u5c3e\u53ef\u80fd\u4f1a\u591a\u51fa\u4e00\u4e2a^M\u7b26\u53f7\u3002<\/p>\n\n\n\n<p>Windows\u521b\u5efa\u7684\u6587\u4ef6\u662f \\n\\r\u7ed3\u675f\u7684\uff0c \u800cLinux\u7b49\u7c7bUnix\u64cd\u4f5c\u7cfb\u7edf\u662f\\n\u7ed3\u675f\u7684\u3002\u6240\u4ee5Unix\u7684\u6587\u672c\u5230Windows\u4f1a\u51fa\u73b0\u6362\u884c\u4e22\u5931\uff08ultraedit\u8fd9\u7c7b\u8f6f\u4ef6\u53ef\u4ee5\u6b63\u786e\u8bc6\u522b\uff09\uff1b \u800c\u53cd\u8fc7\u6765\u5c31\u4f1a\u51fa\u73b0^M\u7684\u7b26\u53f7\u4e86<\/p>\n\n\n\n<p>Windows\u7b49\u64cd\u4f5c\u7cfb\u7edf\u7528\u7684\u6587\u672c\u6362\u884c\u7b26\u548cUnix\/Linux\u64cd\u4f5c\u7cfb\u7edf\u7528\u7684\u4e0d\u540c\uff0cWindows\u7cfb\u7edf\u4e0b\u8f93\u5165\u7684\u6362\u884c\u7b26\u5728Unix\/Linux\u4e0b\u4e0d\u4f1a\u663e\u793a\u4e3a\u201c\u6362\u884c\u201d\uff0c\u800c\u662f\u663e\u793a\u4e3a ^M \u8fd9\u4e2a\u7b26\u53f7\uff08\u8fd9\u662fLinux\u7b49\u7cfb\u7edf\u4e0b\u89c4\u5b9a\u7684\u7279\u6b8a\u6807\u8bb0\uff0c\u5360\u4e00\u4e2a\u5b57\u7b26\u5927\u5c0f\uff0c\u4e0d\u662f ^ \u548c M \u7684\u7ec4\u5408\uff0c\u6253\u5370\u4e0d\u51fa\u6765\u7684\uff09\u3002Linux\u4e0b\u5f88\u591a\u6587\u672c\u7f16\u8f91\u5668\uff08\u547d\u4ee4\u884c\uff09\u4f1a\u5728\u663e\u793a\u8fd9\u4e2a\u6807\u8bb0\u4e4b\u540e\uff0c\u8865\u4e0a\u4e00\u4e2a\u81ea\u5df1\u7684\u6362\u884c\u7b26\uff0c\u4ee5\u907f\u514d\u5185\u5bb9\u6df7\u4e71\uff08\u53ea\u662f\u7528\u4e8e\u663e\u793a\uff0c\u8865\u5145\u7684\u6362\u884c\u7b26\u4e0d\u4f1a\u5199\u5165\u6587\u4ef6\uff0c\u6709\u4e13\u95e8\u7684\u547d\u4ee4\u5c06Windows\u6362\u884c\u7b26\u66ff\u6362\u4e3aLinux\u6362\u884c\u7b26\uff09\u3002 Unix\/Linux\u7cfb\u7edf\u4e0b\u7684\u6362\u884c\u7b26\u5728Windows\u7cfb\u7edf\u7684\u6587\u672c\u7f16\u8f91\u5668\u4e2d\u4f1a\u88ab\u5ffd\u7565\uff0c\u6574\u4e2a\u6587\u672c\u4f1a\u4e71\u6210\u4e00\u56e2\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-27-1024x248.png\" alt=\"\" class=\"wp-image-12751\" width=\"552\" height=\"133\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-27-1024x248.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-27-300x73.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-27-768x186.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-27-830x201.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-27-230x56.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-27-350x85.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-27-480x116.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-27.png 1378w\" sizes=\"(max-width: 552px) 100vw, 552px\" \/><\/figure><\/div>\n\n\n\n<p>\u627e\u4e00\u4efdlinux\u4e0a\u7f16\u8f91\u7684\u6587\u6863\u548c\u4e00\u4efdwindows\u4e0a\u7f16\u8f91\u7684\u6587\u6863\uff0c\u7528notepad++\u67e5\u770b\uff0c\u8bbe\u7f6e\u663e\u793a\u6240\u6709\u7b26\u53f7\uff0c\u4e00\u76ee\u4e86\u7136\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-28-1024x286.png\" alt=\"\" class=\"wp-image-12752\" width=\"579\" height=\"161\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-28-1024x286.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-28-300x84.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-28-768x214.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-28-1536x428.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-28-830x231.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-28-230x64.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-28-350x98.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-28-480x134.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-28.png 1922w\" sizes=\"(max-width: 579px) 100vw, 579px\" \/><\/figure><\/div>\n\n\n\n<p>\u56e0\u6b64\u7ecf\u5e38\u5728\u4e24\u4e2a\u5e73\u53f0\u95f4\u4f20\u8f93\u6587\u4ef6\u7ecf\u5e38\u4f1a\u5728\u6362\u884c\u7b26\u4e0a\u51fa\u95ee\u9898\uff0c\u7f51\u7edc\u4e0a\u6709\u5f88\u591a\u8f6c\u6362\u6362\u884c\u7b26\u7684\u65b9\u6cd5\uff0c\u968f\u4fbf\u767e\u5ea6\u5c31\u6709\uff0c\u770b\u4f60\u7528\u4ec0\u4e48\u7f16\u8f91\u5668\u3002<\/p>\n\n\n\n<p>\u8fd9\u4e24\u4e2a\u7b26\u53f7\u7684\u5dee\u5f02\uff0c\u4f1a\u5bfc\u81f4\u6587\u4ef6\u683c\u5f0f\u4e0d\u540c\u3002<\/p>\n\n\n\n<p>\u6bd4\u5982\u4f1a\u5bfc\u81f4 CRLF \u7684\u6587\u4ef6\uff0c\u60f3\u8981\u5728 Linux \u7cfb\u7edf\u6267\u884c\uff0c\u5c31\u4f1a\u51fa\u95ee\u9898\u3002<\/p>\n\n\n\n<p>\u4e3e\u4f8b\u6765\u8bf4\uff0c\u6211\u5728 Windows \u4e0b\u65b0\u5efa\u4e00\u4e2a Shell \u811a\u672c\u6587\u4ef6\uff0c\u884c\u5c3e\u6362\u884c\u7b26\u662f CRLF \u683c\u5f0f\u7684\uff0c\u90a3\u4e48\u6b64\u65f6\u653e\u5230 Linux \u7cfb\u7edf\u6267\u884c\uff0c\u662f\u4f1a\u62a5\u9519\uff0c\u65e0\u6cd5\u6267\u884c\u7684\u3002<\/p>\n\n\n\n<p><strong>Git \u6362\u884c\u7b26\u81ea\u52a8\u8f6c\u6362<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u8fd9\u91cc\u5148\u6307\u5b9a\u4e24\u4e2a\u975e\u5b98\u65b9\u7684\u6982\u5ff5\uff0c\u65b9\u4fbf\u540e\u9762\u89e3\u91ca\u4e0e\u63cf\u8ff0\uff1a<strong>(\u91cd\u8981\uff0c\u5426\u5219\u540e\u9762\u770b\u4e0d\u61c2)<\/strong><\/p>\n\n\n\n<ol><li><strong>\u6807\u51c6\u5316<\/strong> \u6307\u5728\u63d0\u4ea4\u4ee3\u7801\u5230git\u6570\u636e\u5e93(\u672c\u5730\u5e93) \u4e2d\u5c06\u6587\u672c\u6587\u4ef6\u4e2d\u7684\u6362\u884c\u7b26CRLF\u8f6c\u4e3aLF\u7684\u8fc7\u7a0b<\/li><li><strong>\u8f6c\u6362<\/strong> \u6307\u5728\u68c0\u51faGit\u6570\u636e\u5e93\u4ee3\u7801\u8fc7\u7a0b\u4e2d\u5c06\u6587\u672c\u6587\u4ef6\u4e2d\u7684\u6362\u884c\u7b26LF\u8f6c\u6362\u4e3aCRLF\u7684\u8fc7\u7a0b<\/li><\/ol>\n\n\n\n<p><strong>core.autocrlf &amp; core.safecrlf<\/strong><\/p>\n\n\n\n<p>Git \u63d0\u4f9b\u4e86\u4e00\u4e2a\u540d\u4e3a <code>core.autocrlf<\/code> \u7684\u914d\u7f6e\uff0c\u53ef\u4ee5\u81ea\u52a8\u5b8c\u6210\u6807\u51c6\u5316\u4e0e\u8f6c\u6362\u3002\u5b83\u7684\u8bbe\u7f6e\u65b9\u5f0f\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">git config --global core.autocrlf  [true | input | false]  # \u5168\u5c40\u8bbe\u7f6e\ngit config --local core.autocrlf  [true | input | false] # \u9488\u5bf9\u672c\u9879\u76ee\u8bbe\u7f6e<\/pre>\n\n\n\n<ul><li><strong>true<\/strong> \u81ea\u52a8\u5b8c\u6210\u6807\u51c6\u5316\u4e0e\u8f6c\u6362<\/li><li><strong>input<\/strong> \u53ea\u505a\u6807\u51c6\u5316\u64cd\u4f5c\uff0c\u4e0d\u505a\u8f6c\u6362\u64cd\u4f5c<\/li><li><strong>false<\/strong> \u63d0\u4ea4\u4e0e\u68c0\u51fa\u7684\u4ee3\u7801\u90fd\u4fdd\u6301\u6587\u4ef6\u539f\u6709\u7684\u6362\u884c\u7b26\u4e0d\u53d8<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">CRLF \u4e0e LF \u6df7\u5408\u7684\u6587\u672c\u6587\u4ef6\u4e0d\u53d7\u6b64\u914d\u7f6e\u63a7\u5236\u3002\nGit \u5b89\u88c5\u540e\u9ed8\u8ba4\u4e3a false<\/pre>\n\n\n\n<p>\u6240\u4ee5\uff0c\u4e00\u79cd\u89c4\u8303\u6362\u884c\u7b26\u7684\u65b9\u5f0f\u662f\u8fd9\u6837\u7684<\/p>\n\n\n\n<p>\u4f7f\u7528 Windows \u7cfb\u7edf\u7684\u5f00\u53d1\u8005\u8bbe\u7f6e\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">git config --global core.aurocrlf true\n\n# Windows \u6253\u5f00 autocrlf\n# pull \u65f6\u8f6c\u6362\u4e3a CRLF \uff0cpush \u65f6\u8f6c\u6362\u4e3a LF<\/pre>\n\n\n\n<p>\u4f7f\u7528 Linux\/MacOS \u7684\u5f00\u53d1\u8005\u8bbe\u7f6e\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">git config --global core.autocrlf input<\/pre>\n\n\n\n<p>\u7531\u4e8e\u6ca1\u6709\u4e00\u4e2a\u7edd\u5bf9\u6709\u6548\u7684\u7b97\u6cd5\u6765\u5224\u65ad\u4e00\u4e2a\u6587\u4ef6\u662f\u5426\u4e3a\u6587\u672c\uff0c\u6240\u4ee5Git \u63d0\u4f9b\u4e86\u4e00\u9879\u7981\u6b62\/\u8b66\u544a\u4e0d\u53ef\u9006\u8f6c\u6362\u7684\u914d\u7f6e\u6765\u9632\u6b62\u9519\u8bef\u7684\u6807\u51c6\u5316\u4e0e\u8f6c\u6362\u3002\u5b83\u4e3b\u8981\u662f\u5f71\u54cd\u5230\u591a\u79cd\u6362\u884c\u7b26\u6df7\u5408\u7684\u6587\u4ef6\uff0c\u6211\u4eec\u53ef\u4ee5\u624b\u52a8\u5c06\u5176\u8f6c\u6362\u4e3a\u540c\u4e00\u79cd\u6362\u884c\u7b26\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">git config --global core.safecrlf [true | false | warn]<\/pre>\n\n\n\n<ul><li><strong>true<\/strong> \u7981\u6b62\u63d0\u4ea4\u6df7\u5408\u6362\u884c\u7b26\u7684\u6587\u672c\u6587\u4ef6(<code>git add<\/code> \u7684\u65f6\u5019\u4f1a\u88ab\u62e6\u622a\uff0c\u63d0\u793a\u5f02\u5e38)<\/li><li><strong>warn<\/strong> \u63d0\u4ea4\u6df7\u5408\u6362\u884c\u7b26\u7684\u6587\u672c\u6587\u4ef6\u7684\u65f6\u5019\u53d1\u51fa\u8b66\u544a\uff0c\u4f46\u662f\u4e0d\u4f1a\u963b\u6b62 <code>git add<\/code> \u64cd\u4f5c<\/li><li><strong>false<\/strong> \u4e0d\u7981\u6b62\u63d0\u4ea4\u6df7\u5408\u6362\u884c\u7b26\u7684\u6587\u672c\u6587\u4ef6\uff08\u9ed8\u8ba4\u914d\u7f6e\uff09<\/li><\/ul>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-30-1024x721.png\" alt=\"\" class=\"wp-image-12754\" width=\"342\" height=\"240\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-30-1024x721.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-30-300x211.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-30-768x541.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-30-830x585.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-30-230x162.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-30-350x247.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-30-480x338.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-30.png 1184w\" sizes=\"(max-width: 342px) 100vw, 342px\" \/><\/figure><\/div>\n\n\n\n<p>\u53ef\u4ee5\u8fd0\u884c git config &#8211;list \u67e5\u770b\u5f53\u524d\u914d\u7f6e<\/p>\n\n\n\n<p>\u82e5\u8fd0\u884cgit config &#8211;list\uff0c\u5176\u4e2d\u6ca1\u6709\u51fa\u73b0autocrlf\u8bbe\u7f6e\uff0c\u5219\u9ed8\u8ba4\u4e3afalse\uff0c\u5373\u4e0d\u5bf9git\u9879\u76ee\u7684\u884c\u5c3e\u7b26\u505a\u4efb\u4f55\u5904\u7406\u3002<\/p>\n\n\n\n<p><strong>gitattributes \u6587\u4ef6<\/strong><\/p>\n\n\n\n<p>core.autocrlf \u7684\u914d\u7f6e\u4f9d\u8d56\u4e8e\u6bcf\u4e00\u4f4d\u53c2\u4e0e\u9879\u76ee\u7684\u5f00\u53d1\u673a\u5668\u4e0a\u7684\u914d\u7f6e\uff0c\u8fd9\u5f88\u96be\u786e\u4fdd\u6bcf\u4e2a\u4eba\u90fd\u80fd\u6b63\u786e\u914d\u7f6e\u3002\u4e8e\u662f\u5728\u89c4\u8303\u9879\u76ee\u4e2d\u7684\u6362\u884c\u7b26\u65b9\u9762\uff0c\u8fd8\u6709\u4e00\u5957\u6dfb\u52a0\u914d\u7f6e\u6587\u4ef6\u7684\u65b9\u6848\u3002\u5728\u9879\u76ee\u7684\u6839\u76ee\u5f55\u4e0b\u53ef\u4ee5\u6dfb\u52a0\u4e00\u4e2a.gitattributes \u6587\u4ef6\u3002\u5b83\u7684\u4f18\u5148\u7ea7\u9ad8\u4e8ecore.autocrlf\u7684\u8bbe\u7f6e\uff0c\u53ef\u4ee5\u8986\u76d6core.autocrlf\u7684\u3002\u5b83\u7c7b\u4f3c\u4e8e .gitignore \u6587\u4ef6\uff0c\u968f\u63d0\u4ea4\u4fee\u6539\u751f\u6548\uff0c\u4e00\u4e2a\u9879\u76ee\u4e2d\u53ef\u4ee5\u7ef4\u6301\u4e00\u4efd\u76f8\u540c\u7684\u914d\u7f6e\u3002\u6240\u4ee5\uff0c\u5b83\u80fd\u591f\u907f\u514d\u6bcf\u4e2a\u5f00\u53d1\u4eba\u5458\u914d\u7f6e\u4e0d\u540c\u7684\u95ee\u9898\u3002<\/p>\n\n\n\n<p>.gitattributes\u6587\u4ef6\u7684\u529f\u80fd\u4e0d\u53ea\u6709\u914d\u7f6e\u6362\u884c\u7b26\uff0c\u6240\u4ee5\u5b83\u7684\u914d\u7f6e\u76f8\u5bf9\u590d\u6742\u4e00\u4e0b\u3002\u8be6\u7ec6\u7684\u8bf4\u660e\u6587\u6863\u53ef\u4ee5\u53c2\u8003 <a href=\"http:\/\/schacon.github.io\/git\/gitattributes.html\" target=\"_blank\" rel=\"noreferrer noopener\">\u5730\u5740<\/a>\u3002\u8fd9\u91cc\u53ea\u9488\u5bf9\u6362\u884c\u7b26\u7684\u914d\u7f6e\u505a\u4e00\u4e0b\u7b80\u5355\u7684\u4ecb\u7ecd\uff1a<\/p>\n\n\n\n<p>\u6bcf\u884c\u57fa\u672c\u5f62\u5f0f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">filter attr1 attr2 ....<\/pre>\n\n\n\n<p>filter \u4ee3\u8868\u5339\u914d\u6587\u4ef6\u7684\u901a\u914d\u7b26\uff0c\u5728\u5b83\u540e\u9762\u8ddf\u7740\u76f8\u5e94\u7684\u5c5e\u6027\uff0c\u7528\u7a7a\u683c\u95f4\u9694\u3002<\/p>\n\n\n\n<p>filter \u7684\u9009\u9879\u6bd4\u8f83\u7b80\u5355\uff0c\u5e38\u89c1\u7684\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">* \u5339\u914d\u6240\u6709\u6587\u4ef6\n*.txt  \u5339\u914d\u6587\u4ef6\u540d\u4ee5txt\u7ed3\u5c3e\u7684\u6587\u4ef6<\/pre>\n\n\n\n<p>attr\u7684\u9009\u62e9\u6bd4\u8f83\u591a\uff0c\u5176\u4e2d\u4e0e\u6362\u884c\u7b26\u76f8\u5173\u7684\u5c5e\u6027\u53ea\u6709\u51e0\u6761\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-29-1024x799.png\" alt=\"\" class=\"wp-image-12753\" width=\"382\" height=\"298\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-29-1024x799.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-29-300x234.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-29-768x600.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-29-830x648.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-29-230x180.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-29-350x273.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-29-480x375.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/09\/\u56fe\u7247-29.png 1094w\" sizes=\"(max-width: 382px) 100vw, 382px\" \/><\/figure><\/div>\n\n\n\n<p>\u8fd9\u91cc\u7ed9\u51fa\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u6765\u8bf4\u660e\u4e00\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">*         text=auto\n# These files are text and should be normalized (convert crlf => lf)\n*.cs      text\n*.xaml    text\n*.csproj  text\n*.sln     text\n*.tt      text\n*.ps1     text\n*.cmd     text\n*.msbuild text\n*.md      text\n\n# Images should be treated as binary\n# (binary is a macro for -text -diff)\n*.png     binary\n*.jepg    binary\n\n*.sdf     binary\n<\/pre>\n\n\n\n<p>\u9664\u4e86\u4e0b\u9762\u5339\u914d\u5230\u7684\u6587\u4ef6\uff0c\u5269\u4e0b\u7684\u4f9d\u8d56Git \u51b3\u5b9a\u662f\u5426\u53c2\u4e0e\u6807\u51c6\u5316\u4e0e\u8f6c\u6362\u3002\u4e0a\u9762\u4e00\u6bb5\u662f\u53c2\u4e0e\u6807\u51c6\u5316\u4e0e\u8f6c\u6362\u7684\u6587\u4ef6\uff1b\u4e0b\u9762\u4e00\u6bb5\u662f\u4e0d\u53c2\u4e0e\u6807\u51c6\u5316\u4e0e\u8f6c\u6362\u7684\u6587\u4ef6\uff1b<\/p>\n\n\n\n<p>\u5176\u5b9e\uff0c\u5728\u6587\u4ef6\u91cc\u53ea\u6709\u4e0b\u9762\u8fd9\u884c\u914d\u7f6e\u7684\u65f6\u5019\uff0c\u5c31\u76f8\u5f53\u4e8e\u6839\u636e\u64cd\u4f5c\u7cfb\u7edf\u81ea\u52a8\u586b\u5165 core.autocrlf \u7684\u8bbe\u7f6e\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">* text=auto<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \u6700\u8fd1\u5728\u4f7f\u7528 Git \u63d0\u4ea4\u4ee3\u7801\u7684\u65f6\u5019\uff0c\u8001\u662f\u78b0\u5230\u4e00\u6bb5\u770b\u8d77\u6765 \u201c\u6ca1\u6709\u4efb\u4f55\u6539\u52a8\u201d \u7684\u4ee3\u7801\uff0c\u88ab diff \u68c0\u6d4b\u51fa\u5f02 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/12749"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=12749"}],"version-history":[{"count":4,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/12749\/revisions"}],"predecessor-version":[{"id":12758,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/12749\/revisions\/12758"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12749"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12749"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12749"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}