Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git过滤器分支表示工作树是脏的,而不是脏的_Git_Command Line - Fatal编程技术网

Git过滤器分支表示工作树是脏的,而不是脏的

Git过滤器分支表示工作树是脏的,而不是脏的,git,command-line,Git,Command Line,我正试图在git存储库中重写我的历史记录,因为我需要删除包含受限信息的文件 情况就是这样: $ git filter-branch --index-filter 'git rm --cached --ignore-unmatch FILE' master Cannot rewrite branch(es) with a dirty working directory. 所以我认为“这很奇怪,我很确定我没有未提交的更改”,我运行: $ git status -u # On branch mast

我正试图在git存储库中重写我的历史记录,因为我需要删除包含受限信息的文件

情况就是这样:

$ git filter-branch --index-filter 'git rm --cached --ignore-unmatch FILE' master
Cannot rewrite branch(es) with a dirty working directory.
所以我认为“这很奇怪,我很确定我没有未提交的更改”,我运行:

$ git status -u
# On branch master
nothing to commit (use -u to show untracked files)
这是怎么回事?有人知道会发生什么吗?此存储库中有子模块

子模块暂存信息 我有18个子模块(所有Vim插件),下面是它们的状态。我想这可能是有用的信息

$ for i in $(ls); do cd $i; git status -u; cd ..; done;
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# On branch master
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
其他信息
这主要是猜测,但错误可能是由GitV1.7.7.1中的一个bug引起的(该bug是在您最初的帖子发布之后发布的)。从提交消息:

过滤器分支已经要求我们在开始之前有一个干净的工作树。但是,它在检查之前没有刷新索引,这意味着在统计脏数据的情况下它可能是错误的


运行
git status
后是否再次尝试
filter branch
?也许只有一个文件的时间戳改变了,
filter branch
没有检查它来删除脏标记是的,我检查过了。同样的结果。那么这很可能是由于子模块,我没有任何经验,对不起,
git status-u
显示了什么?您是否也尝试过删除任何未跟踪的文件,或者在一个全新的克隆上执行此操作?粘贴的命令不会给出子模块状态,而是多次给出相同的超级模块状态。请检查以下命令的退出状态:“git diff files--ignore submodules--quiet”,“git diff index--cached--quiet HEAD--”在1.7.7.1之前(我有1.7.0.4),您可能需要强制git刷新索引。我发现您可以通过运行
git stash
然后
git stash apply
来实现这一点,就好像您确实有一个脏的工作目录(取自)。Git会抱怨,但过滤器分支应该可以工作。如果有人有一个不那么黑客的方法,那么请在这里提到它@J-P:我的答案中链接的修复程序导致
git filter branch
运行以下命令来刷新索引:
git update index-q——忽略子模块——刷新
从1.7.1切换到1.8.3.4,为我解决了这个问题。我在尝试通过
$ git diff-files --ignore-submodules --quiet
$ echo $?
1
$ git diff-index --cached --quiet HEAD --
$ echo $?
0