我可以隐藏正在进行的合并吗? 我正在为Git合并解决冲突,但我想暂时回到干净的状态,而不会丢失我在合并上已经完成的工作。如果我尝试git隐藏,我会为每个冲突尚未解决的文件获取错误:“需要合并”

我可以隐藏正在进行的合并吗? 我正在为Git合并解决冲突,但我想暂时回到干净的状态,而不会丢失我在合并上已经完成的工作。如果我尝试git隐藏,我会为每个冲突尚未解决的文件获取错误:“需要合并”,git,merge,git-stash,Git,Merge,Git Stash,是否有一种保存正在进行的合并的好方法?我唯一的想法是将回购协议克隆到另一个文件夹中,但这似乎太过分了 您可以使用git worktree命令在其他文件夹中添加新的工作树。这类似于第二个索引和工作树,但使用相同的git repo曼吉特工作树: Manage multiple working trees attached to the same repository. A git repository can support multiple working trees, allowi

是否有一种保存正在进行的合并的好方法?我唯一的想法是将回购协议克隆到另一个文件夹中,但这似乎太过分了

您可以使用
git worktree
命令在其他文件夹中添加新的工作树。这类似于第二个索引和工作树,但使用相同的git repo<代码>曼吉特工作树:

   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.

如果您在本地克隆存储库,它将不会在磁盘上保留回购历史记录的单独副本,至少在Unix系统上是这样。因此,如果您有10GB的历史记录,但有100MB的文件,那么您将只使用额外的100MB。正在进行的合并存储在索引和工作树中。考虑到
git stash
在这两个提交中进行了两次提交,您可能会认为这是正确的选择,但正在进行的合并状态不能存储在提交中:它包含git不会写入树中的元数据。可以修改
stash
脚本,将原始索引文件内容保存到自己的blob中,但这会变得相当棘手。今晚我不想尝试编写代码。:-)重新克隆回购协议似乎是最好的快速方法。克隆就是为了这个。在git文档中。