Visual Studio(Git 提供程序)在所有文件上永久显示“待编辑”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34286119/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 11:38:06  来源:igfitidea点击:

Visual Studio (Git provider) permanently shows "pending edit" on all files

gitvisual-studio

提问by Smitis

I am using VS 2015 Community and Reshaper. My problem is that after pull or commit (using tortoise git client) VS still still shows "pending edit" on almost all files. "Compare with unmodified" show no change not event whitespaces. This getting me crazy because I want to see "pending edit" only on files I am actually working on ...

我正在使用 VS 2015 Community 和 Reshaper。我的问题是,在拉取或提交(使用乌龟 git 客户端)之后,VS 仍然在几乎所有文件上显示“待编辑”。“与未修改的比较”显示没有变化而不是事件空白。这让我发疯了,因为我只想在我实际处理的文件上看到“待编辑”......

EDIT: I just find that problem is with CRLF setting in git. I need line end with CRLF but git returns LF.

编辑:我只是发现问题在于 git 中的 CRLF 设置。我需要以 CRLF 结尾,但 git 返回 LF。

EDIT 2: After new informations I did following step which works for me:

编辑 2:在获得新信息后,我执行了以下对我有用的步骤:

  1. Set line endings to CRLF: git config --global core.autocrlf true
  2. Clear git indexes: git rm --cached -r .
  3. Rewrite indexes - pick up all the new line endings: git reset --hard
  1. 将行尾设置为 CRLF: git config --global core.autocrlf true
  2. 清除 git 索引: git rm --cached -r .
  3. 重写索引 - 选择所有新行结尾: git reset --hard

More about line endings for windows here.

更多关于 windows 的行结尾在这里

回答by Tobiah Zarlez

I have heard of this before being caused by the "end of line" character in your files.

我之前听说过这是由文件中的“行尾”字符引起的。

Try running this:

尝试运行这个:

git config --global core.autocrlf false

git config --global core.autocrlf false

回答by Andrew Webb

Seeing as this is Windows, the recommendationis to set core.autocrlfto true:-

鉴于这是 Windows,建议设置core.autocrlf为 true:-

git config --global core.autocrlf true

git config --global core.autocrlf true

Then, if the problem still persists in VS 2015 for your solution, check the solution's .gitattributesfile. Mine contained:-

然后,如果问题在 VS 2015 中仍然存在以获取解决方案,请检查解决方案的.gitattributes文件。我的包含:-

* text=auto

* 文字=自动

which was causing unwanted Pending Edits to still be shown (in VS 2015 but not in TortoiseGit). I didn't need the .gitattributesfile, so I deleted it, and then everything displayed as it should in VS 2015.

这导致仍然显示不需要的待处理编辑(在 VS 2015 中,但不在 TortoiseGit 中)。我不需要该.gitattributes文件,所以我删除了它,然后所有内容在 VS 2015 中都按原样显示。