如何从Git存储库中删除包含文件的单个目录?


当前回答

你可以试试这个:git rm-rf<目录名>

它将强制删除目录。

其他回答

从Git和本地删除目录

使用两个目录签出“master”:

git rm -r one-of-the-directories // This deletes from filesystem
git commit . -m "Remove duplicated directory"
git push origin <your-git-branch> (typically 'master', but not always)

从Git中删除目录,但不是本地目录

要从Git中删除此目录,但不将其从文件系统(本地)中完全删除,请执行以下操作:

git rm -r --cached myFolder

这两个答案的组合对我有用

git rm -r one-of-the-directories
git commit . -m "Remove duplicated directory"
git push

如果仍然显示一些警告,请手动删除文件

git filter-branch --tree-filter 'rm -rf path/to/your/file' HEAD
git push

转到git目录,然后键入以下命令:rm-rf<目录名>

删除目录后,通过以下方式提交更改:gitcommit-m“您的提交消息”

然后只需在远程GIT目录上推送更改:git推送原点<分支名称>

我通常使用gitadd-all从远程存储库中删除文件/文件夹

rm -r folder_name
git add --all
git commit -m "some comment"
git push origin master

master可以被存储库的任何其他分支替换。

你可以试试这个:git rm-rf<目录名>

它将强制删除目录。