我正在解决 git merge 的冲突,但我想暂时回到干净的状态,而不会丢失我已经在 merge 中完成的工作。如果我尝试 git stash,我会得到每个尚未解决冲突的文件的错误:“需要 merge ”。
有什么好的方法可以保存正在进行的 merge 吗?我唯一的想法是将 repo 克隆到另一个文件夹中,但这似乎太过分了。
最佳答案
您可以使用 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.
关于git - 我可以 git stash 正在进行的 merge 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34685407/