admin管理员组文章数量:1314442
So I did "git init" in the wrong folder and now want to undo it (I want to do it in a subfolder of the current folder). Like I want to delet the hidden .git folder.
I already searched for some solution like "rm -rf .git" or "rmdir .git" but this does not work. (even in the administrator PowerShell)
When I do "rmdir .git" there is an error "Permission Denied". I also tried it in administrator powershell but i get the same error.
.git\hooks cannot
be removed: You do not have sufficient access rights to perform this operation.
In line:1 Character:1
+ rmdir .git
+ ~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (hooks:DirectoryInfo) [Remove-Item], IOException
+ FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand
rmdir : The element C:\Users\...\.git\info cannot be
be removed: You do not have sufficient access permissions to perform this operation.
In line:1 Character:1
It is also strange that when i enter "git status" it shows that it is not a git repository? But when I list the hidden folder "ls -Hidden" then there is a folder named .git??
git status
fatal: not a git repository (or any of the parent directories): .git
ls -Hidden
Mode LastWriteTime Length Name
---- ------------- ------ ----
darh-l 30.01.2025 10:25 .git
cd .git
ls
Mode LastWriteTime Length Name
---- ------------- ------ ----
dar--l 30.01.2025 10:25 hooks
dar--l 30.01.2025 10:25 info
dar--l 30.01.2025 10:23 objects
dar--l 30.01.2025 10:23 refs
Thanks in advance.
So I did "git init" in the wrong folder and now want to undo it (I want to do it in a subfolder of the current folder). Like I want to delet the hidden .git folder.
I already searched for some solution like "rm -rf .git" or "rmdir .git" but this does not work. (even in the administrator PowerShell)
When I do "rmdir .git" there is an error "Permission Denied". I also tried it in administrator powershell but i get the same error.
.git\hooks cannot
be removed: You do not have sufficient access rights to perform this operation.
In line:1 Character:1
+ rmdir .git
+ ~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (hooks:DirectoryInfo) [Remove-Item], IOException
+ FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand
rmdir : The element C:\Users\...\.git\info cannot be
be removed: You do not have sufficient access permissions to perform this operation.
In line:1 Character:1
It is also strange that when i enter "git status" it shows that it is not a git repository? But when I list the hidden folder "ls -Hidden" then there is a folder named .git??
git status
fatal: not a git repository (or any of the parent directories): .git
ls -Hidden
Mode LastWriteTime Length Name
---- ------------- ------ ----
darh-l 30.01.2025 10:25 .git
cd .git
ls
Mode LastWriteTime Length Name
---- ------------- ------ ----
dar--l 30.01.2025 10:25 hooks
dar--l 30.01.2025 10:25 info
dar--l 30.01.2025 10:23 objects
dar--l 30.01.2025 10:23 refs
Thanks in advance.
Share Improve this question asked Jan 30 at 11:29 PluscheinPluschein 12 bronze badges 2- just cut paste .git folder – TheGameiswar Commented Jan 30 at 11:32
- 2 Thanks, i was able to show the hidden folder in the editor and then delete it;) – Pluschein Commented Jan 30 at 12:12
1 Answer
Reset to default 0I already searched for some solution like "rm -rf .git" or "rmdir .git" but this does not work. (even in the administrator PowerShell)
Likely not a permission-related problem then (as the repository files don't normally have any special permissions anyway). Might be that some program is holding a handle to the directory (your IDE, antivirus programs, third-party Explorer extensions, etc). Reboot to see if the problem goes away. If not, try running a chkdsk /f
scan.
It is also strange that when i enter "git status" it shows that it is not a git repository? But when I list the hidden folder "ls -Hidden" then there is a folder named .git??
It is missing half the contents that would identify it as a Git repository (because you deleted those). For example, it no longer has .git\HEAD
or .git\config
.
本文标签: powershellDelete git in WindowsStack Overflow
版权声明:本文标题:powershell - Delete .git in Windows - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741969614a2407755.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论