在 rebase 或 cherry-pick 操作后 --quit 是否为您留下干净的索引和工作树?

does --quit leave you with a clean index and worktree after a rebase or a cherry-pick operation?

我知道 --quit 不会更改您的 HEAD 指针,因此在 rebase 或 cherrypick 期间成功进行的任何提交仍然存在。

但是我不确定的是,万一在cherry-pick或者rebase过程中发生冲突,是否使用--quit清除冲突带来的变化,比如成功添加的变化,工作目录中的冲突标记、索引中的多个版本等?

git rebase documentation有以下内容:

--quit Abort the rebase operation but HEAD is not reset back to the original branch. The index and working tree are also left unchanged as a result.

cherry-pick documentation 不太清楚对索引和工作树的影响:

--quit Forget about the current operation in progress. Can be used to clear the sequencer state after a failed cherry-pick or revert.

但是 SO 中的 具有以下内容:

But if you choose --quit, Git terminates the rebase without moving HEAD, so that you wind up with:

but a clean index and work-tree. So you don't have to be clever enough to attach a branch name before the --quit.

那是哪一个?我知道在合并中 --quit 不会清除合并冲突在您的索引和工作树中造成的混乱,它只是放弃合并头状态。如果是 cherry pick 或 rebase,它有什么不同吗?

这实际上取决于您发出 --quit 时的状态:Git 就停在这里。我将更新另一个答案以表明您可以 git reset --hard 将其设为“干净”(如果需要),或者将其保留为“脏”(如果需要)。