git status 显示修改,git checkout --;不删除它们
我想删除对我的工作副本的所有更改。
运行 git status
显示已修改的文件。
我所做的一切似乎都无法删除这些修改。
例如:
rbellamy@PROMETHEUS /d/Development/rhino-etl (master)
$ git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: Rhino.Etl.Core/Enumerables/CachingEnumerable.cs
# modified: Rhino.Etl.Core/Pipelines/SingleThreadedPipelineExecuter.cs
# modified: Rhino.Etl.Tests/Rhino.Etl.Tests.csproj
# modified: Rhino.Etl.Tests/SingleThreadedPipelineExecuterTest.cs
#
no changes added to commit (use "git add" and/or "git commit -a")
rbellamy@PROMETHEUS /d/Development/rhino-etl (master)
$ git checkout -- Rhino.Etl.Core/Enumerables/CachingEnumerable.cs
rbellamy@PROMETHEUS /d/Development/rhino-etl (master)
$ git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: Rhino.Etl.Core/Enumerables/CachingEnumerable.cs
# modified: Rhino.Etl.Core/Pipelines/SingleThreadedPipelineExecuter.cs
# modified: Rhino.Etl.Tests/Rhino.Etl.Tests.csproj
# modified: Rhino.Etl.Tests/SingleThreadedPipelineExecuterTest.cs
#
no changes added to commit (use "git add" and/or "git commit -a")
rbellamy@PROMETHEUS /d/Development/rhino-etl (master)
$ git checkout `git ls-files -m`
rbellamy@PROMETHEUS /d/Development/rhino-etl (master)
$ git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: Rhino.Etl.Core/Enumerables/CachingEnumerable.cs
# modified: Rhino.Etl.Core/Pipelines/SingleThreadedPipelineExecuter.cs
# modified: Rhino.Etl.Tests/Rhino.Etl.Tests.csproj
# modified: Rhino.Etl.Tests/SingleThreadedPipelineExecuterTest.cs
#
no changes added to commit (use "git add" and/or "git commit -a")
rbellamy@PROMETHEUS /d/Development/rhino-etl (master)
$ git reset --hard HEAD
HEAD is now at 6c857e7 boo libraries updated to 2.0.9.2 and rhino.dsl.dll updated.
rbellamy@PROMETHEUS /d/Development/rhino-etl (master)
$ git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: Rhino.Etl.Core/Enumerables/CachingEnumerable.cs
# modified: Rhino.Etl.Core/Pipelines/SingleThreadedPipelineExecuter.cs
# modified: Rhino.Etl.Tests/Rhino.Etl.Tests.csproj
# modified: Rhino.Etl.Tests/SingleThreadedPipelineExecuterTest.cs
#
no changes added to commit (use "git add" and/or "git commit -a")
I would like to remove all changes to my working copy.
Running git status
shows files modified.
Nothing I do seems to remove these modifications.
E.g.:
rbellamy@PROMETHEUS /d/Development/rhino-etl (master)
$ git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: Rhino.Etl.Core/Enumerables/CachingEnumerable.cs
# modified: Rhino.Etl.Core/Pipelines/SingleThreadedPipelineExecuter.cs
# modified: Rhino.Etl.Tests/Rhino.Etl.Tests.csproj
# modified: Rhino.Etl.Tests/SingleThreadedPipelineExecuterTest.cs
#
no changes added to commit (use "git add" and/or "git commit -a")
rbellamy@PROMETHEUS /d/Development/rhino-etl (master)
$ git checkout -- Rhino.Etl.Core/Enumerables/CachingEnumerable.cs
rbellamy@PROMETHEUS /d/Development/rhino-etl (master)
$ git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: Rhino.Etl.Core/Enumerables/CachingEnumerable.cs
# modified: Rhino.Etl.Core/Pipelines/SingleThreadedPipelineExecuter.cs
# modified: Rhino.Etl.Tests/Rhino.Etl.Tests.csproj
# modified: Rhino.Etl.Tests/SingleThreadedPipelineExecuterTest.cs
#
no changes added to commit (use "git add" and/or "git commit -a")
rbellamy@PROMETHEUS /d/Development/rhino-etl (master)
$ git checkout `git ls-files -m`
rbellamy@PROMETHEUS /d/Development/rhino-etl (master)
$ git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: Rhino.Etl.Core/Enumerables/CachingEnumerable.cs
# modified: Rhino.Etl.Core/Pipelines/SingleThreadedPipelineExecuter.cs
# modified: Rhino.Etl.Tests/Rhino.Etl.Tests.csproj
# modified: Rhino.Etl.Tests/SingleThreadedPipelineExecuterTest.cs
#
no changes added to commit (use "git add" and/or "git commit -a")
rbellamy@PROMETHEUS /d/Development/rhino-etl (master)
$ git reset --hard HEAD
HEAD is now at 6c857e7 boo libraries updated to 2.0.9.2 and rhino.dsl.dll updated.
rbellamy@PROMETHEUS /d/Development/rhino-etl (master)
$ git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: Rhino.Etl.Core/Enumerables/CachingEnumerable.cs
# modified: Rhino.Etl.Core/Pipelines/SingleThreadedPipelineExecuter.cs
# modified: Rhino.Etl.Tests/Rhino.Etl.Tests.csproj
# modified: Rhino.Etl.Tests/SingleThreadedPipelineExecuterTest.cs
#
no changes added to commit (use "git add" and/or "git commit -a")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(25)
我在 Windows 上遇到了这个问题,但不准备研究使用 config --global core.autocrlf false 的后果,我也不准备放弃我的存储中的其他私有分支和好东西并从一个新的克隆开始。我只需要完成一些事情。现在。
这对我有用,因为你让 git 完全重写你的工作目录:(
请注意,仅运行
git reset --hard
还不够好,也不是简单的rm
code> 在重置
之前的文件上,如原始问题的评论中所建议的那样)I was having this problem on Windows but wasn't prepared to look into the ramifications of using
config --global core.autocrlf false
I also wasn't prepared to abandon other private branches and goodies in my stash and start with a fresh clone. I just need to get something done. Now.This worked for me, on the idea that you let git rewrite your working directory completely:
(Note that running just
git reset --hard
wasn't good enough nor was a plainrm
on the files before thereset
as are suggested in the comments to the original question)有多种问题可能导致此行为:
行结束规范化
我也遇到过此类问题。归结为 git 自动将 crlf 转换为 lf。这通常是由单个文件中的混合行结尾引起的。该文件在索引中被规范化,但是当 git 再次对其进行非规范化以将其与工作树中的文件进行比较时,结果是不同的。
但如果你想解决这个问题,你应该禁用 core.autocrlf,将所有行结尾更改为 lf,然后再次启用它。或者您可以通过以下方式完全禁用它:
您还可以考虑使用 而不是 core.autocrlf
.gitattributes
文件。这样,您可以确保使用存储库的每个人都使用相同的规范化规则,从而防止混合行结尾进入存储库。如果您希望 git 在执行不可逆标准化时发出警告,还可以考虑设置 core.safecrlf 来发出警告。
git 手册页这样说:
不区分大小写的文件系统
在不区分大小写的文件系统上,当存储库中存在具有不同大小写的相同文件名时,git 会尝试检出这两个文件,但最终只有一个文件出现在文件系统上。当 git 尝试比较第二个文件时,它会将其与错误的文件进行比较。
解决方案要么切换到不区分大小写的文件系统,但这在大多数情况下是不可行的,要么重命名并提交另一个文件系统上的文件之一。
There are multiple problems that can cause this behaviour:
Line ending normalization
I've had these kinds of problems too. It comes down to git automatically converting crlf to lf. This is typically caused by mixed line endings in a single file. The file gets normalized in the index, but when git then denormalizes it again to diff it against the file in the working tree, the result is different.
But if you want to fix this, you should disable core.autocrlf, change all line endings to lf, and then enable it again. Or you can disable it altogether by doing:
Instead of core.autocrlf, you can also consider using
.gitattributes
files. This way, you can make sure everyone using the repo uses the same normalization rules, preventing mixed line endings getting into the repository.Also consider setting core.safecrlf to warn if you want git to warn you when a non-reversible normalization would be performed.
The git manpages say this:
Case-insensitive file systems
On case-insensitive filesystems, when the same filename with different casing is in the repository, git tries to checkout both, but only one ends up on the file system. When git tries to compare the second one, it would compare it to the wrong file.
The solution would either be switching to a non-case insensitive filesystem, but this in most cases is not feasible or renaming and committing one of the files on another filesystem.
另一个可能对人们有用的解决方案,因为没有一个文本选项对我有用:
.gitattributes
的内容替换为一行:* binary
。这告诉 git 将每个文件视为它无法执行任何操作的二进制文件。git checkout --
将它们恢复到存储库版本git checkout -- .gitattributes
以恢复.gitattributes
code> 文件恢复到其初始状态Another solution that may work for people, since none of the text options worked for me:
.gitattributes
with a single line:* binary
. This tells git to treat every file as a binary file that it can't do anything with.git checkout -- <files>
to restore them to the repository versiongit checkout -- .gitattributes
to restore the.gitattributes
file to its initial state对于未来遇到此问题的人:更改文件模式也可能会出现相同的症状。
git config core.filemode false
将修复它。For future people having this problem: Having filemode changes can also have the same symptoms.
git config core.filemode false
will fix it.这让我发疯,尤其是如果没有网上找到的任何解决方案,我就无法解决这个问题。这是我解决问题的方法。不能在这里获得学分,因为这是同事的工作:)
问题根源:我最初安装的 git 在 Windows 上没有自动行转换。这导致我最初对 GLFW 的承诺没有正确的行结尾。
设置:
Xubuntu 12.04
包含 glfw 项目的 Git 存储库
问题:无法重置 glfw 文件。无论我尝试什么,它们总是显示为已修改。
已解决:
This has been driving me crazy, especially that I couldn`t fix this without any of the solutions found online. Here is how I solved it. Can't take the credits here since this is the work of a colleague :)
Source of the problem: My initial installation of git was without auto line conversion on windows. This caused my initial commit to GLFW to be without the proper line ending.
Setup:
Xubuntu 12.04
Git repo with glfw project
Problem: Unable to reset glfw files. They always show as modified, regardless of what I tried.
Solved:
我有一个具有相同问题的 .bat 文件(无法在未跟踪的文件中删除它)。 git checkout -- 不起作用,此页面上的任何建议也不起作用。唯一对我有用的事情是:
然后删除存储:
I had a .bat file with the same problem (couldn't get rid it it in untracked files). git checkout -- didn't work, neither did any of the suggestions on this page. The only thing that worked for me was to do:
And then to delete the stash:
同样的问题遇到两次了!两次我都隐藏了一些更改,然后尝试将它们弹出。无法弹出更改,因为我有很多已更改的文件 - 但它们没有!它们完全一样。
我现在认为我已经尝试了上述所有解决方案但没有成功。在尝试之后,
我现在几乎修改了存储库中的所有文件。
比较文件时,它说我已删除所有行,然后再次添加它们。
有点令人不安。我现在将避免将来隐藏。
唯一的解决方案是克隆一个新的存储库并重新开始。 (上次做过)
Got the same issue twice! Both times when stash some changes I made and then tried to pop them back. Could'nt pop the changes since I've got lots of file that are changed -- but they are NOT! They are EXACTLY the same.
I now think I've tried all the above solutions without success. After trying the
I now got almost all the files in my repository modified.
When diffing the file, it says I've deleted all the lines and then add them again.
Kind of disturbing. I will now avoid stashing in the future..
The only solution is to clone a new repository and start over. (Made it last time)
尝试做一个
这应该清除当前工作本地存储库中的所有更改
Try doing a
That should clear all the changes in the current working local repo
通常,在 GIT 中清除所有修改&新文件,以下 2 个命令应该可以很好地工作(小心,这将删除您可能创建的所有新文件+文件夹,并将所有修改的文件恢复到 的状态)当前提交):
也许有时更好的选择是使用可选消息执行“git stash push”,如下所示:
这也会清除所有新文件和修改过的文件,但您将把所有文件都隐藏起来,以防万一你想恢复它们。 GIT 中的存储可以从一个分支转移到另一个分支,因此如果您愿意,您可以将它们恢复到不同的分支中。
附带说明一下,如果您已经暂存了一些新添加的文件并想要删除它们,这应该可以解决问题:
如果以上所有内容都不适合您,请阅读以下内容不久前对我有用的方法:
我之前几次遇到过这个问题。我目前正在我的雇主提供的 Windows 10 机器上进行开发。今天,这种特殊的 git 行为是由我从“开发”分支创建一个新分支引起的。由于某种原因,在我切换回“develop”分支后,一些看似随机的文件仍然存在,并在“git status”中显示为“已修改”。
另外,那时我无法签出另一个分支,所以我被困在我的“开发”分支上。
这就是我所做的:
我注意到今天早些时候从“develop”创建的新分支显示在第一个“commit”消息中,在末尾引用“HEAD ->development,origin/develop,origin/HEAD, 我今天早些时候创建的分支”。
因为我并不真正需要它,所以我删除了它:
更改的文件仍然显示,所以我这样做了:
这解决了我的问题:
当然
$ git stash list
将显示隐藏的更改,因为我的存储很少,也不需要任何存储,我执行了$ git stash clear
来删除所有存储。注意:我还没有尝试过按照之前有人建议的那样操作:
这可能也有效,下次遇到这个问题时我一定会尝试一下。
Normally, in GIT to clear all your modifications & new files the following 2 commands should work very nicely (be CAREFUL, this will delete all your new files+folders you may have created & will restore all your modified files to the state of your current commit):
Maybe a better option sometimes is just doing "git stash push" with optional message, like so:
This will also clear all your new and modified files, but you'll have all of them stashed in case you want to restore them. Stash in GIT carries from branch to branch, so you can restore them in a different branch, if you wish to.
As a side note, in case you have already staged some newly added files and want to get rid of them, this should do the trick:
If all of the above doesn't work for you, read below what worked for me a while ago:
I ran into this problem few times before. I'm currently developing on Windows 10 machine provided by my employer. Today, this particular git behavior was caused by me creating a new branch from my "develop" branch. For some reason, after I switched back to "develop" branch, some seemingly random files persisted and were showing up as "modified" in "git status".
Also, at that point I couldn't checkout another branch, so I was stuck on my "develop" branch.
This is what I did:
I noticed that the new branch I created from "develop" earlier today was showing in the first "commit" message, being referenced at the end "HEAD -> develop, origin/develop, origin/HEAD, The-branch-i-created-earlier-today".
Since I didn't really need it, I deleted it:
The changed files were still showing up, so I did:
This solved my problem:
Of course
$ git stash list
will show stashed changes, and since I had few and didn't need any of my stashes, I did$ git stash clear
to DELETE ALL STASHES.NOTE: I haven't tried doing what someone suggested here before me:
This may have worked as well, I'll be sure to try it next time I run into this problem.
我只能通过临时删除存储库的 .gitattributes 文件(定义
* text=auto
和*.c text
)来解决此问题。删除后我运行了 git status ,修改消失了。即使 .gitattributes 放回原位后,它们也没有返回。
I was only able to fix this by temporary deleting my repo's .gitattributes file (which defined
* text=auto
and*.c text
).I ran
git status
after deleting and the modifications were gone. They didn't return even after .gitattributes was put back in place.我遇到的问题是 Windows 不关心文件名大小写,但 git 关心。因此 git 存储了文件的小写和大写版本,但只能签出一个。
The issue that I ran into is that windows doesn't care about filename capitalization, but git does. So git stored a lower and uppercase version of the file but could only checkout one.
我有一个较旧的冗余分支,具有不同的行结尾。切换到这个让我有点卡住,直到我应用了一些 --force 。
接下来是一个快速的
gitbranch -Dbronchbranch
。I had an older redundant branch with different line-endings. Switching to this got me a bit stuck until I applied some --force.
Followed by a swift
git branch -D brokenbranch
.具有一致的行结尾是一件好事。例如,它不会触发不必要的合并,尽管这是微不足道的。我见过 Visual Studio 创建具有混合行结尾的文件。
此外,某些程序(例如 bash(在 Linux 上))确实要求 .sh 文件以 LF 结尾。
为了确保发生这种情况,您可以使用 gitattributes。无论 autcrlf 的值是多少,它都在存储库级别上工作。
例如,你可以有这样的 .gitattributes:
* text=auto
如果对您的情况确实重要,您还可以更具体地说明每个文件类型/扩展名。
然后autocrlf可以在本地转换Windows程序的行结尾。
在混合 C#/C++/Java/Ruby/R、Windows/Linux 项目上,此功能运行良好。到目前为止没有问题。
Having consistent line endings is a good thing. For example it will not trigger unnecessary merges, albeit trivial. I have seen Visual Studio create files with mixed line endings.
Also some programs like bash (on linux) do require that .sh files are LF terminated.
To make sure this happens you can use gitattributes. It works on repository level no matter what the value of autcrlf is.
For example you can have .gitattributes like this:
* text=auto
You can also be more specific per file type/extension if it did matter in your case.
Then autocrlf can convert line endings for Windows programs locally.
On a mixed C#/C++/Java/Ruby/R, Windows/Linux project this is working well. No issues so far.
我也有同样的症状,但是由不同的原因引起的。
我无法:
即使
git rm --cached app.js
它标记为已删除,并且在未跟踪的文件中我可以看到 app.js。但是当我再次尝试 rm -rf app.js 和 peform git status 时,它仍然显示“未跟踪”中的文件。经过与同事几次尝试后,我们发现这是由 Grunt 引起的!
由于 Grunt 已打开,并且 app.js 是从其他几个 js 文件生成的,我们发现每次使用 js 文件(也是此 app.js)操作后,grunt 都会重新创建 app。又是js。
I had also same symptoms but has been caused by different thing.
I was not able to:
even on
git rm --cached app.js
it signs as deleted and in untracked files I could see app.js. But when I triedrm -rf app.js
and peformgit status
again it still shows me the file in 'untracked'.After couple of tries with colleague we found out, that it has been caused by Grunt!
As the
Grunt
has been turned on, and because app.js has been generated from couple of other js files we found out that after each operation with js files (also this app.js) grunt recreate app.js again.当存储库的贡献者在 Linux 计算机上工作或使用 Cygwin 且文件权限发生更改的 Windows 时,也可能会出现此问题。 Git 只知道 755 和 644。
此问题的示例以及如何检查它:
为了避免这种情况,您应该确保使用正确设置 git
This issue can also occur when a contributor to the repo works on a Linux machine, or windows with Cygwin and file permissions are changed. Git only knows of 755 and 644.
Example of this issue and how to check for it:
To avoid this, you should make sure you setup git correctly using
这里有很多解决方案,在我想出自己的解决方案之前,我也许应该尝试其中的一些。不管怎样,还有一个……
我们的问题是我们没有强制执行endlines,并且存储库混合了DOS / Unix。更糟糕的是,它实际上是一个处于这个位置的开源存储库,并且我们已经分叉了。那些拥有操作系统存储库主要所有权的人决定将所有行尾更改为 Unix,并且提交了包含
.gitattributes
的内容来强制行尾。不幸的是,这似乎会导致类似于此处描述的问题,一旦完成 DOS-2-Unix 之前的代码合并,文件将永远被标记为已更改并且无法恢复。
在我对此的研究过程中,我遇到了 - https://help .github.com/articles/dealing-with-line-endings/ - 如果我再次遇到这个问题,我会首先尝试一下。
这是我所做的:
我' d 最初进行了合并,然后意识到我遇到了这个问题,不得不中止 -
git reset --hard HEAD
(我遇到了合并冲突。我怎样才能中止合并?)我在VIM 并更改为 Unix (
:set ff=unix
)。可以使用像dos2unix
这样的工具来代替commited
合并
master
(master有DOS-2-Unix)更改)git checkout 旧代码分支;
git merge master
解决了冲突,文件再次变为 DOS,因此在 VIM 中时必须
:set ff=unix
。 (注意我已经安装了 https://github.com/itchyny/lightline.vim ,它允许我查看 VIM 状态行上的文件格式是什么)There are a lot of solutions here and I maybe should have tried some of these before I came up with my own. Anyway here is one more ...
Our issue was that we had no enforcement for endlines and the repository had a mix of DOS / Unix. Worse still was that it was actually an open source repo in this position, and which we had forked. The decision was made by those with primary ownership of the OS repository to change all endlines to Unix and the commit was made that included a
.gitattributes
to enforce the line endings.Unfortunately this seemed to cause problems much like described here where once a merge of code from before the DOS-2-Unix was done the files would forever be marked as changed and couldn't be reverted.
During my research for this I came across - https://help.github.com/articles/dealing-with-line-endings/ - If I face this problem again I would first start by trying this out.
Here is what I did:
I'd initially done a merge before realising I had this problem and had to abort that -
git reset --hard HEAD
(I ran into a merge conflict. How can I abort the merge?)I opened the files in question in VIM and changed to Unix (
:set ff=unix
). A tool likedos2unix
could be used instead of coursecommitted
merged the
master
in (the master has the DOS-2-Unix changes)git checkout old-code-branch;
git merge master
Resolved conflicts and the files were DOS again so had to
:set ff=unix
when in VIM. (Note I have installed https://github.com/itchyny/lightline.vim which allowed me to see what the file format is on the VIM statusline)我提交了所有更改,然后执行并撤消了提交。
这对我有用
git add 。
git commit -m“随机提交”
git reset --hard HEAD~1
I commited all the changes and then did and undo on the commit.
This worked for me
git add .
git commit -m "Random commit"
git reset --hard HEAD~1
如果您克隆存储库并立即看到待处理的更改,则该存储库处于不一致状态。请不要从
.gitattributes
文件中注释掉* text=auto
。这是专门放在那里的,因为存储库的所有者希望所有文件都以 LF 行结尾一致地存储。正如 HankCa 所说,按照 https://help.github 上的说明进行操作。 com/articles/dealing-with-line-endings/ 是解决问题的方法。简单按钮:
然后将分支合并(或拉取请求)到存储库的所有者。
If you clone a repository and instantly see pending changes, then the repository is in an inconsistent state. Please do NOT comment out
* text=auto
from the.gitattributes
file. That was put there specifically because the owner of the repository wants all files stored consistently with LF line endings.As stated by HankCa, following the instructions on https://help.github.com/articles/dealing-with-line-endings/ is the way to go to fix the problem. Easy button:
Then merge (or pull request) the branch to the owner of the repo.
此页面上的其他内容均不起作用。这终于对我有用了。显示没有未跟踪或已提交的文件。
Nothing else on this page worked. This finally worked for me. Showing no untracked, or commited files.
对我来说,问题是在执行命令
git checkout
时打开了 Visual Studio关闭 Visual Studio 后,该命令起作用了,我终于可以从堆栈中应用我的工作。因此,请检查所有可能更改代码的应用程序,例如 SourceTree、SmartGit、NotePad、NotePad++ 和其他编辑器。
For me the problem was that Visual Studio was opened when performing the command
git checkout <file>
After closing Visual Studio the command worked and I could finally apply my work from the stack. So check all applications that could make changes to your code, for example SourceTree, SmartGit, NotePad, NotePad++ and other editors.
我们公司也面临着类似的情况。所提出的方法都没有对我们有帮助。研究的结果是,问题暴露了。 问题是,Git 中有两个文件,它们的名称仅在符号寄存器上有所不同。 Unix 系统将它们视为两个不同的文件,但 Windows 简直要疯了。 为了解决这个问题,我们删除了服务器上的其中一个文件。之后,在 Windows 上的本地存储库中帮助执行接下来的几个命令(以不同的顺序):
We faced a similar situation in our company. None of the proposed methods did not help us. As a result of the research, the problem was revealed. The thing was that in Git there were two files, the names of which differed only in the register of symbols. Unix-systems saw them as two different files, but Windows was going crazy. To solve the problem, we deleted one of the files on the server. After that, at the local repositories on Windows helped the next few commands (in different sequences):
我通过编辑 .git/config 解决了这个问题,添加:
然后我去了 .git/refs/heads/name_branch
并放置最后一次提交的 ID
在此处输入代码
I solved it by editing .git / config, adding:
Then I went to .git / refs / heads / name_branch
and place the id of the last commit
enter code here
我这样解决了这个问题:
这对我有用。
I solved it this way:
That's what worked for me.
这里提出的一个解决方案不起作用,我发现该文件实际上是一些特殊字符的链接:
One proposed solution here didn't work, I found out the file was actually a link to some special characters:
.gitattributes 与
存储库中实际 CRLF 的文件不太吻合(可能使用 core.autocrlf=false 签入)
解决方案:
--renormalize)
.gitattributes with
doesn't mesh well with the file being actually CRLF in the repo (probably checked in with core.autocrlf=false)
Solution:
--renormalize)