繁体   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