我正在解决一个git合并的冲突,但我想暂时回到一个干净的状态,而不会丢失我已经完成的合并工作。如果我尝试使用git stash,每个冲突未被解决的文件都会出现错误:“需要合并”。 有没有好的方法可以保存正在进行中的合并?我唯一的想法是将存储库克隆到另一个文件夹中,但这似乎过于复杂。
你可以使用git worktree
命令在不同的文件夹中添加新的工作树。这就像第二个索引和工作树,但使用相同的git repo。man git-worktree
:
Manage multiple working trees attached to the same repository.
A git repository can support multiple working trees, allowing you to check out
more than one branch at a time. With git worktree add a new working tree is
associated with the repository. This new working tree is called a "linked working
tree" as opposed to the "main working tree" prepared by "git init" or "git clone".
A repository has one main working tree (if it’s not a bare repository) and zero or
more linked working trees.