windows 无法完全删除git存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2384057/
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-09 07:09:27  来源:igfitidea点击:

Cannot remove git repository completely

windowsgitgit-remote

提问by Aleyna

I have been using git on windows-msysgit. Whenever I try to remove a repository completely either using explorer or using

我一直在 windows-msysgit 上使用 git。每当我尝试使用资源管理器或使用完全删除存储库时

$ git rm -rf ptp/
fatal: Not a git repository (or any of the parent directories): .git

it errors out "The data present in the reparse point buffer is invalid" or the fatal error above.

它会出错“重新分析点缓冲区中存在的数据无效”或上面的致命错误。

What's wrong with me/git?

我/git有什么问题?

Thanks in advance

提前致谢

回答by rmk

To remove a git repo, just do rm -rf ptp/. That's it. git rmis used to move items from the index [the staging area for changes / new files], not to delete git repositories.

要删除 git repo,只需执行rm -rf ptp/. 就是这样。 git rm用于从索引 [更改/新文件的暂存区] 中移动项目,而不是删除 git 存储库。

回答by Dmytrii Nagirniak

To get rid of the git repository on Windows do this:

要摆脱 Windows 上的 git 存储库,请执行以下操作:

Win+R, Type cmd, Enter.

Win+R cmd,输入,回车。

> cd c:/path/to/parent/of/ptp-repo
> rmdir /S /Q ptp

Or if it fails then check who locks the directoryand delete it by hands from Explore.

或者,如果失败,则检查谁锁定了目录并从“浏览”中手动删除它。

Most likely some process holds a lockon files/dirs in your repo.

很可能某个进程锁定了您的存储库中的文件/目录。

回答by Stef Joosten

I tried to remove GIT on my windows-XP, by means of the Windows/Configuration/Software menu. After some error message (which I cannot remember), it removed all files. I checked it, and there are no files with ptp in the name left on the entire system.

我试图通过 Windows/Configuration/Software 菜单删除 Windows-XP 上的 GIT。在一些错误消息(我不记得了)之后,它删除了所有文件。我查了一下,整个系统上没有留下名字中带有ptp的文件。

A problem remained however: each time I opened windows-explorer, a nasty error message came calling for a dll file that wasn't there anymore.

然而,一个问题仍然存在:每次我打开 windows-explorer 时,都会出现一个令人讨厌的错误消息,要求一个不再存在的 dll 文件。

When checking the registry, there were many traces to GIT left in the registry. I removed them carefully by hand, which seems to have solved the problem. This is of course a dangerous path, but I had no choice. Perhaps it is a good idea to look into the Windows-deinstallation script very carefully.

检查注册表时,注册表中留下了很多GIT的痕迹。我用手小心地取下它们,似乎已经解决了问题。这当然是一条危险的道路,但我别无选择。也许仔细查看 Windows 卸载脚本是个好主意。

Stef Joosten

斯蒂芬·约斯滕

回答by Peteter

On Windows 10, try running cygwin console as admin and rm -rf the dir.

在 Windows 10 上,尝试以管理员身份运行 cygwin 控制台并运行 rm -rf 目录。

回答by andmar8

I have also just experienced this odd problem on windows 10: An empty .git folder simply would not delete and a restart of windows did not remedy it, nor did rmdir .git, nor did rm -rf .git.

我也刚刚在 Windows 10 上遇到了这个奇怪的问题:一个空的 .git 文件夹根本不会删除,并且重新启动 Windows 也没有解决它,也没有rmdir .git,也没有rm -rf .git

Similarly to another suggestion, I used ubuntu (instead of cygwin) for windows (https://tutorials.ubuntu.com/tutorial/tutorial-ubuntu-on-windows#0) and issued an rm -rf .git, that worked perfectly

与另一个建议类似,我将 ubuntu(而不是 cygwin)用于 Windows(https://tutorials.ubuntu.com/tutorial/tutorial-ubuntu-on-windows#0)并发布了一个rm -rf .git,效果很好

回答by g19fanatic

When I want to remove a GIT repo on Windows... i very simply delete (or move) the .git directory where the repo sits... I do this straight from Explorer... it hasn't failed me yet!

当我想在 Windows 上删除 GIT 存储库时...我非常简单地删除(或移动)存储库所在的 .git 目录...我直接从资源管理器中执行此操作...它还没有让我失望!

回答by Brady Trainor

I have a third partition, on a dual boot with Windows 7 and Fedora Linux, and I realized I had a file open in vim in a terminal, and that was causing a .fuse_hidden...file to not be deletable.

我有第三个分区,在 Windows 7 和 Fedora Linux 的双引导上,我意识到我在终端中的 vim 中打开了一个文件,这导致.fuse_hidden...文件无法删除。

When I closed the file in vim, I was able to delete the .gitdirectory.

当我在 vim 中关闭文件时,我能够删除该.git目录。