當我執行 git status 時,我得到以下影像檔案已更改。然而,它是唯一的影像檔案,檔案中不應有任何 LF/CRLF,
$ git status
# HEAD detached at origin/master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: public/css/chosen-sprite.png
當我輸入 git diff 以查看我得到的更改時。
$ git diff public/css/chosen-sprite.png
warning: CRLF will be replaced by LF in public/css/chosen-sprite.png.
The file will have its original line endings in your working directory.
diff --git a/public/css/chosen-sprite.png b/public/css/chosen-sprite.png
index c57da70..0476a8f 100644
Binary files a/public/css/chosen-sprite.png and b/public/css/chosen-sprite.png differ
所以我所做的是嘗試檢查檔案以確保它與遠程源檔案相同。所以我在下面做了
$git checkout public/css/chosen-sprite.png
但是沒有對檔案或 git status 做任何更改,仍然顯示為更改。關于如何解決這個問題的任何想法?
uj5u.com熱心網友回復:
默認情況下,git 將所有檔案視為文本,并在具有非 LF 行結尾的機器(例如 windows)上使用它時轉換行結尾。如果您希望它將檔案視為二進制檔案(而不是轉換行尾),您必須在 .gitattributes 檔案中將其標識為二進制檔案。就像是
*.png binary
應該做的伎倆。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/368836.html
標籤:混帐
上一篇:如何判斷提交是否屬于本地專案
