git仓库中的文件都被删除和未跟踪,但它们仍然存在。这怎么可能? [英] files in the git repo are both deleted and untracked but they're still there. How is that possible?

查看:773
本文介绍了git仓库中的文件都被删除和未跟踪,但它们仍然存在。这怎么可能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


$ b

<$ c $回购中的所有(数百个)文件现在显示为未跟踪并已删除,但我无法弄清楚发生了什么事情? c> ls 显示文件在目录中





但是 git status。在目录中具有已删除和未跟踪的文件。几个月后我还没有碰过这些文件。此外,该网站的文件是现在不工作...



解决方案

这种情况可能是由您正在使用的IDE引起的。可能出现的情况AFAIK可能是这样的:您已经从您的IDE中删除了四个文件(dashicons.eot,.svg,....) ,它可能有一个git插件来跟踪已更改的文件。



2-经过一段时间,您更改了这些文件并重新添加了这些文件,但IDE git插件hasn还没有同步,或者您已经从IDE外部恢复了它们。



要查看这些文件中git跟踪的最终有效结果,我建议:

  git reset< file-name> 

将要为< file-name> code>或者只是简单的

$ g $ p $ g $ g $ reset
code $



这将在终端或IDE插件中取消所有使用 git add 执行的文件。 p>

然后,

  git status 


$ b 现在,您可以再次添加它们并进行修改,并且不会将删除应用于您的存储库,包括本地和远程存储库。


All the (hundreds of) files in my repo now show up as untracked and deleted though I can't figure out what's going on?

ls shows the files are in the directory

but git status . in the directory has the files as deleted and untracked. I haven't touched any of these files in a couple months. Also the website the files are for is not working now...

解决方案

The situation may have been caused by the IDE that you are working with. The possible scenario, AFAIK may have been this :

1- You have deleted the four files ( dashicons.eot, .svg, .... ), from your IDE, which probably has a git plugin to track the changed files.

2- After some time, you changed those file and added them again, but either the IDE git plugin hasn't synced yet or you have restored them from outside of the IDE.

To see what a final valid result for git tracking in these files would be, I recommend :

git reset <file-name>

to unstage changes to be committed for <file-name> or just simply

git reset

which will unstage all file that were staged with git add, either in the terminal or by the IDE plugin.

Then,

git status

I assume you should now see that your files (dashicons) are modified, not deleted

Now you can add them again and commit your modifications and no deletion will be applied to your repository, both local and remote.

这篇关于git仓库中的文件都被删除和未跟踪,但它们仍然存在。这怎么可能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆