windows - 如何解决Github for Windows 中的 "Wall of Pink"?

标签 windows github

我在 Windows 7 上使用 Github for Windows,有时它会显示一些文件的粉红色墙,即使该文件根本没有被修改(如下图所示)。我找到了 an article谈论这个,但我没有找到一个好的解决方案。 有没有办法让 Github for windows 正常工作,而不是将我文件中的 CRLF 字符更改为 LF?我喜欢CRLF....

wall of pink

最佳答案

I like CRLF....

每个人都在 Windows 上这样做 ;-)

除了 Git 更喜欢在内部存储带有 LF 行结束分隔符的文本。

但是,您可以同时拥有:工作目录中的 CRLF 和 git 对象数据库中的 LF。有一个 git 内置机制可以为您提供便利。

确实如 Scott Hanselman's post 中所述,

[...]you can do what GitHub for Windows suggests with text=auto (and create a .gitattributes file per repo containing the following lines).

# Auto detect text files and perform LF normalization 
* text=auto

What's text=auto do?

This ensures that all files that git considers to be text will have normalized (LF) line endings in the repository. The core.eol configuration variable controls which line endings git will use for normalized files in your working directory; the default is to use the native line ending for your platform, or CRLF if core.autocrlf is set.

另一个非常有用的内容是 Tim Clem 的帖子 Mind the End of Your Line 。这很好地解释了 Git 行结尾的原因和方法。

更新

nulltoken, I have .gitattributes in my project folder, and it has text=auto, but the github client just show me pink walls again and again.

根据您在上面的评论,下面是一些需要考虑的额外要点。这将要求您切换到命令行以运行一些 git 命令。

  • 确保 .gitattributes文件已提交,不仅位于您的项目文件夹中。
  • 为了不丢失任何东西,请确保您没有任何未决的更改(例如,运行 git status 应该输出类似 nothing to commit, working directory clean 的内容)
  • 运行 git checkout-index --force * .考虑到 .gitattributes 中的指令,这将在您的工作目录中重新创建所有文件。文件。完成此操作后,工作目录中的每个文本文件都将带有 CRLF 行结尾和 git status应该仍然认为工作目录是干净的。
  • 从现在开始,创建新提交时不应出现粉红墙。

注意:粉红色的墙可能仍然会出现,同时显示您的历史记录中两次提交之间的更改,这些更改是在包含 .gitattributes 的提交之前创建的文件。

关于windows - 如何解决Github for Windows 中的 "Wall of Pink"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19394754/

相关文章:

NASM 程序集中的 Windows API 蜂鸣功能

linux - 为什么我的数值算法在两台不同的机器上表现不同?

git - Git无法 merge 无关分支

C++异常裸抛

windows - 使用Rundll32复制SUBST的功能

c++ - StartService 失败,错误代码为 1053

visual-studio - 将 VSTS 构建状态添加到 GitHub 页面

github - 使用 Npm 从 github 安装特定分支

gitignore 不会忽略 .suo Visual Studio 文件

Github SSH 访问 : Permission denied (publickey)