我正在解决git merge的冲突,但我想暂时回到干净的状态而不会丢失我已经在合并上完成的工作。如果我尝试git stash,我会为尚未解决冲突的每个文件收到错误:“need merge”。
是否有一种很好的方法来保存合并进度?我唯一的想法就是将repo克隆到另一个文件夹中,但这似乎过分了。
答案 0 :(得分:1)
您可以使用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.