簡體   English   中英

為什么我不能拉/重新設置我的Git存儲庫?

[英]Why can't I pull/rebase my Git repository?

我有一個本地Git存儲庫,我正在嘗試與遠程存儲庫同步。 有一個二進制文件,我沒有碰過。 但是由於某些奇怪的原因,我無法變基:

git config --local core.autocrlf false
git reset --hard --quiet
git clean --force -d
git fetch --quiet
git checkout master
Already on "master"
git rebase --abort
git stash 
warning: CRLF will be replaced by LF in test_assets/favicon.ico.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in test_assets/favicon.ico.
The file will have its original line endings in your working directory.
git rebase --strategy-option=theirs origin/master
Cannot rebase: You have unstaged changes.
Please commit or stash them.

M   test_assets/favicon.ico

我能做什么?

favicon.ico文件通常是二進制文件 您的Git警告:

 warning: CRLF will be replaced by LF in test_assets/favicon.ico. 

告訴我們,您可能(無意間)指示Git將其視為文本文件。

因此,當Git從存儲庫中出來時,它會按照您的指示修改文件。 這就是為什么它顯示為已修改的原因,以及為什么在提交要告訴Git的更改之前無法合並或重新設置基數的原因。

解決方案是停止告訴Git該文件是文本。 這是一個有點硬你通知Git該文件是文本,因為有這些東西多種機制肯定地說,但如果你有一個.gitattributes文件,你可以用它來告訴Git的這個文件,實際上任何通過添加以下行,名為*.ico文件絕對不是文本:

*.ico   -text

到該.gitattributes文件(然后您可以git addgit commit進行具有更新的.gitattributes的新提交)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM