From 823f767fc9bc0984ca104a7bf55388fe00d4f533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=A5=E6=B5=A9?= Date: Thu, 17 Oct 2024 12:01:34 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0=20README.md=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20.gitattributes=20=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 7 +++++++ README.md | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/.gitattributes b/.gitattributes index 43f7ec9..fd24067 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,10 @@ +# 如果你先推送了一个.jpg文件,然后再推送包含.gitattributes文件的更新,Git不会自动重新处理之前的.jpg文件的属性。为使.gitattributes中的新规则生效,你可以通过以下步骤重新应用设置: + +# 1. 删除本地缓存的.jpg文件:git rm --cached .jpg +# 2. 重新添加该文件:git add .jpg +# 3. 再次提交并推送:git commit -m "Apply .gitattributes changes" && git push + +# 这样,Git将按照.gitattributes中的新规则处理该文件。 * text=auto # Force the following filetypes to have unix eols, so Windows does not break them diff --git a/README.md b/README.md index 5b9f18f..6c8d1d3 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,28 @@ pnpm run dev ln -s $(which pnpm) $HOME/.local/bin/pnpm ``` +### .gitattributes + +如果你先推送了一个.jpg文件,然后再推送包含.gitattributes文件的更新,Git不会自动重新处理之前的.jpg文件的属性。为使.gitattributes中的新规则生效,你可以通过以下步骤重新应用设置: + +```bash +1. 删除本地缓存的.jpg文件:git rm --cached .jpg +2. 重新添加该文件:git add .jpg +3. 再次提交并推送:git commit -m "Apply .gitattributes changes" && git push +``` + +这样,Git将按照.gitattributes中的新规则处理该文件。 + +要验证.gitattributes文件中的二进制配置是否生效,可以使用以下方法: + +```bash +1. 推送后验证:先按照之前步骤重新添加并推送.jpg文件。 +2. 查看差异(diff):执行 git diff,检查文件是否有文本形式的改动。如果是二进制文件,Git不会显示具体内容的差异。 +3. Git日志验证:执行 git log -p .jpg 查看提交的改动记录,确认文件未受行尾或编码处理的影响。 +``` + +如果以上测试显示该文件未发生不必要的改动,说明.gitattributes配置已生效。 + ## Links - [Performance API优化页面性能](https://juejin.cn/post/7238779568478552122)