我将 --intent-to-add
选项与 git add
一起使用,以便使用 git commit -a
轻松添加文件。然而,这似乎混淆了 git stash
。例如:
git init
touch a
git add a
git commit -m 1
touch b
git add --intent-to-add b
git stash --include-untracked
给出 git stash
的输出:
error: Entry 'b' not uptodate. Cannot merge.
Cannot save the current worktree state
为什么会这样?能修好吗?
最佳答案
鉴于 git stash
后跟 git stash pop
无论如何都会清除索引,我会从 git reset --keep
开始清除索引。 (使用 --keep
,这不会更改您的本地文件或您的提交,它只会清除索引。)
git reset --keep
git stash --include-untracked
一旦你完成了你需要 stash 的东西,你必须重做 git add --intent-to-add b
因为你用重置取消了它:
git stash pop
git add --intent-to-add b
至于为什么会发生这种情况,我不知道。对我来说似乎是一个错误......毕竟你可以存储一个普通的 git add
。
关于git - 存储使用 --intent-to-add 添加的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34763805/