Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

无法删除仓库 #66

Open
Yanshuimuxqh opened this issue Jan 20, 2024 · 4 comments
Open

无法删除仓库 #66

Yanshuimuxqh opened this issue Jan 20, 2024 · 4 comments

Comments

@Yanshuimuxqh
Copy link

命令git rm --cached 2024InToD
报错:error: the following file has staged content different from both the
file and the HEAD:
2024InToD
(use -f to force removal)
也无法直接删除仓库对应的本地文件

@RnTs1002
Copy link

刚好也遇到这种问题,但是我在网上查找到的资料说git rm --cached这个命令是用来删除文件的,git rm -r --cached是用来删除文件夹的,似乎不是仓库……
以下复制帖子原文供参考:
就可以使用git rm命令,两种选择:
git rm --cached “文件的位置或者路径” //会从git缓存中删除,但是不会物理的从硬盘删除;
git rm --f “文件的位置或者路径” //会从缓存中删除,还会直接从硬盘删除,连从垃圾箱找回的机会都不给你哦

git删除已经add的文件的两种方法:
用版本库内容清空暂存区,git reset HEAD (谨慎使用)
只把特定文件从暂存区删除,git rm --cached xxx

@Yanshuimuxqh
Copy link
Author

$ git rm --cached -f 2024InToD
rm '2024InToD'
这样应该是从Git的暂存区中移除了,但是在这个文件夹下重新向一个新仓库推送时候遇到了一个仓库嵌套的报错
$ git add .
warning: adding embedded git repository: 2024InToD
hint: You've added another git repository inside your current repository.
hint: Clones of the outer repository will not contain the contents of
hint: the embedded repository and will not know how to obtain it.
hint: If you meant to add a submodule, use:
hint:
hint: git submodule add 2024InToD
hint:
hint: If you added this path by mistake, you can remove it from the
hint: index with:
hint:
hint: git rm --cached 2024InToD
hint:
hint: See "git help submodule" for more information.

@cuso4lxt
Copy link

2024InToD的文件夹内部还有一个.git目录吗?如果想保留它的内容,但是不是想以git仓库的形式留下来,就要删除它内部的.git目录。应该是“rm -rf 2024InToD/.git”。如果完全不需要它了也可以从文件系统中直接删除文件夹

@Yanshuimuxqh
Copy link
Author

解决了,后来是删掉了github上面的仓库,然后从最里面一层.git开始往外层删除,没有嵌套的话也可以不用命令行。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants