Git: 从 repo 中删除带有引号和反斜杠的目录
Git: Remove directory with quotes and backslashes from repo
我的 git 存储库中有一个名为
的目录(但不在我的本地系统中)
"my\directory-name"
它包含两个引号和两个反斜杠。
问题是我的存储库中的这个目录无法完全检出内容,因为(错误消息:)git 没有找到名为
的目录
my\directory-name
(我仍然可以单独检查每个其他目录和文件..)
我已经尝试过转义字符..
git rm -r '"my\directory-name"'
git rm -r \"my\\directory-name\"
但 git 没有找到任何匹配的文件。使用 git ls-tree HEAD 我可以在 repo 中看到该目录。
谁能告诉我如何从 git 存储库中删除这样的目录?
听起来目录的添加来自 Linux 主机,或者更准确地说是主机在创建给定名称的目录时没有问题。现在您在检查 windows 上的分支状态时遇到问题,因为无法创建目录。
如果是这种情况,您应该会看到 git 存储库的提交状态与
的检出状态之间的差异
git status
如果是这种情况,那么您可以解决此问题并像这样删除文件:
- 在 linux 框上查看存储库
使用
删除linux结帐中的目录
git rm -r '"the\dir"'
git commit
(用“"the\directory"”这样的单勾号引用名字对我有用)
- 将更改从 linux ceckout
推送到 git 服务器
- 获取并更新 windows 框上的结帐
我无法尝试这个,因为我的问题不知何故自行解决了。我在另一个 Windows 系统上一个一个地检查了 repo 中的文件和目录,"broken" 目录除外。然后,当我下次从我的新工作副本提交时,该目录处于删除模式,所以我可以简单地推送并且该目录已从存储库中删除。
我也遇到了这个问题
git status
产生
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: "201"
我几乎尝试了所有我能想到的组合:
git rm --cached -r "201"
fatal: pathspec '201' did not match any files
git rm --cached -r 201
fatal: pathspec '342200231' did not match any files
git rm --cached -r \342\200\231
fatal: pathspec '201' did not match any files
git rm --cached -r "\342\200\231"
fatal: pathspec '201' did not match any files
git rm --cached -r '"\342\200\231"'
fatal: pathspec '"\342\200\231"' did not match any files
git rm --cached -r '"201"'
fatal: pathspec '"201"' did not match any files
git rm --cached -r '201'
fatal: pathspec '201' did not match any files
git rm --cached -r '\342\200\231'
fatal: pathspec '\342\200\231' did not match any files
git Ubunut 上的版本 2.7.4
我的 git 存储库中有一个名为
的目录(但不在我的本地系统中)"my\directory-name"
它包含两个引号和两个反斜杠。
问题是我的存储库中的这个目录无法完全检出内容,因为(错误消息:)git 没有找到名为
的目录my\directory-name
(我仍然可以单独检查每个其他目录和文件..)
我已经尝试过转义字符..
git rm -r '"my\directory-name"'
git rm -r \"my\\directory-name\"
但 git 没有找到任何匹配的文件。使用 git ls-tree HEAD 我可以在 repo 中看到该目录。
谁能告诉我如何从 git 存储库中删除这样的目录?
听起来目录的添加来自 Linux 主机,或者更准确地说是主机在创建给定名称的目录时没有问题。现在您在检查 windows 上的分支状态时遇到问题,因为无法创建目录。
如果是这种情况,您应该会看到 git 存储库的提交状态与
的检出状态之间的差异git status
如果是这种情况,那么您可以解决此问题并像这样删除文件:
- 在 linux 框上查看存储库
使用
删除linux结帐中的目录git rm -r '"the\dir"'
git commit
(用“"the\directory"”这样的单勾号引用名字对我有用)
- 将更改从 linux ceckout 推送到 git 服务器
- 获取并更新 windows 框上的结帐
我无法尝试这个,因为我的问题不知何故自行解决了。我在另一个 Windows 系统上一个一个地检查了 repo 中的文件和目录,"broken" 目录除外。然后,当我下次从我的新工作副本提交时,该目录处于删除模式,所以我可以简单地推送并且该目录已从存储库中删除。
我也遇到了这个问题
git status
产生
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: "201"
我几乎尝试了所有我能想到的组合:
git rm --cached -r "201"
fatal: pathspec '201' did not match any files
git rm --cached -r 201
fatal: pathspec '342200231' did not match any files
git rm --cached -r \342\200\231
fatal: pathspec '201' did not match any files
git rm --cached -r "\342\200\231"
fatal: pathspec '201' did not match any files
git rm --cached -r '"\342\200\231"'
fatal: pathspec '"\342\200\231"' did not match any files
git rm --cached -r '"201"'
fatal: pathspec '"201"' did not match any files
git rm --cached -r '201'
fatal: pathspec '201' did not match any files
git rm --cached -r '\342\200\231'
fatal: pathspec '\342\200\231' did not match any files
git Ubunut 上的版本 2.7.4