【发布时间】:2023-03-06 03:49:01
【问题描述】:
由于误解,我将其放在.gitattributes文件中:
* text=auto eol=lf
我认为这意味着对于所有文件,git 应该自动检测它是否是文本,如果是文本,则通过将 CRLF 转换为 LF,在将文件添加到 repo 时强制执行 LF-only。我相信它 实际上 确实第二个设置覆盖了第一个设置,并强制 git 将 all 文件视为仅具有 LF 行结尾的文本,甚至是像 PNG 这样的二进制文件。
我现在的情况是其他人添加了二进制文件。我已经签出了包含这些文件的版本。对 repo 进行了进一步的更改。我想提取最新版本(我自己没有更改),然后修复 .gitattributes 文件。但我不能拉,因为 git 认为我有变化。
[64]D:\projects\spark_raw_quotes$ git pull --ff-only
Updating 69f37b0..fced821
error: Your local changes to the following files would be overwritten by merge:
src/avg_price/jars/quotearchive-thrift-assembly-0.1.jar
Please, commit your changes or stash them before you can merge.
Aborting
[64]D:\projects\spark_raw_quotes$ git status
On branch master
Your branch is behind 'origin/master' by 225 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
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: data/quotes_UK1_2015-02-16_23_0_244.thrift.b64.gz
modified: src/avg_price/jars/quotearchive-thrift-assembly-0.1.jar
no changes added to commit (use "git add" and/or "git commit -a")
我无法按照此处的说明进行操作,因为 git 总是 认为我有更改:
Git Pull While Ignoring Local Changes?
文件没有改变,它们只是存在于存储库和磁盘上,带有 CRLF(因为它们是中等大小的二进制文件,这个序列偶尔会发生)并且 git 认识到 .gitattributes 规则说 CRLF 应该是转换为 LF。 (至少,这就是我认为正在发生的事情。)
我可以将存储库克隆到新目录,但我想知道如何正确解决此问题。例如,如果我在这个 repo 中存储了我想要重放的更改,那么我不能把它扔掉并重新克隆?我可以暂时覆盖 .gitattributes 设置,直到我设法应用我的更改并重新与主分支同步?
【问题讨论】:
标签: git