删除文件系统中不存在但合并后保留在git中的幻影文件? [英] Deleting ghost files that don't exist in the file system but are left in git after a merge?

查看:59
本文介绍了删除文件系统中不存在但合并后保留在git中的幻影文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我只是在两个存储库之间进行了合并.在其中一个文件中,文件称为FOOBar,在另一个文件中,文件称为FooBar.合并进行得很好,它正确地识别出这两个文件是彼此重命名的,最后,由于符合命名约定,因此我将所有更改都合并到了FooBar中.完成并提交合并后,执行"git status"将显示未上演的更改,该更改未指向指向FOOBar的提交.除了FOOBar不再存在,只剩下FooBar.

So I just did a merge between two repositories. In one of those a file was called FOOBar and in the other it was called FooBar. The merge went fine, it correctly identified that the two files were renamings of one another, and in the end I kept all the changes merged to FooBar since that fits naming convention. After completing and committing the merge doing a "git status" shows a change not staged for commit pointing to FOOBar. Except FOOBar no longer exists only FooBar is left.

我尝试了"git add.","git checkout-","git clean -f","rm FOOBar","git restore".但毕竟所有这些文件仍显示为未暂存的提交状态,并且不存在于文件系统中.

I have tried "git add .", "git checkout -- .", "git clean -f", "rm FOOBar", "git restore ." but after all of these the files still show up as unstaged for commit and not existing in the file system.

我该怎么做才能摆脱git中的这些文件?

What can I do to get rid of these files in git?

推荐答案

我认为大多数顶级git命令都会对它们在磁盘上找到的文件进行操作,然后在索引中找到要操作的正确文件.由于磁盘上的文件大小写不正确,因此可能会将其绊倒.

I think most top level git commands operate on the files they find on disk, and then locate the correct file in the index to manipulate. Since the files you have on disk has the wrong case, this might be tripping it up.

无论如何,那只是猜测.

Anyway, that's just guesswork.

这里是摆脱它的方法,您必须直接操作索引.

Here's how to get rid of it, you have to manipulate the index directly.

以下命令应删除该文件:

The following command should get rid of the file:

git update-index --remove FOOBar

这篇关于删除文件系统中不存在但合并后保留在git中的幻影文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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