从坏.gitattributes

时间:2015-04-28 12:58:27

标签: git

由于误解,我把它放在.gitattributes文件中:

* text=auto eol=lf

想到这意味着对于所有文件,如果它是文本,git应该自动检测,如果它是文本,只有在将文件添加到repo时,通过将CRLF转换为LF来强制执行LF。我认为实际的确如此,第二个设置会覆盖第一个设置,并强制git将所有文件视为仅使用LF的行结尾的文本,甚至是像PNG这样的二进制文件。

我现在的情况是其他人添加了二进制文件。我检查了包含这些文件的版本。回购已经进行了进一步的修改。我想拉最新版本(我没有自己的更改),然后修复.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。 (至少,这就是我认为的情况。)

我可以将存储库克隆到新目录,但我想知道如何正确地解决这个问题。例如,如果我在这个回购中藏匿了我要重播的更改,那么我不能把它扔掉并重新放弃?我可以暂时覆盖.gitattributes设置,直到我设法应用我的更改并且我又与主分支同步了吗?

1 个答案:

答案 0 :(得分:1)

假设您的工作目录中没有“真正的”更改(即您不关心您的工作目录是否被完全覆盖),以下内容将为您提供最新信息(假设您是主人):{{1 }}。这会将您的git reset --hard origin/master移至指向HEAD,并使用origin/master的内容覆盖您的工作目录和索引。

相关问题