git - 我可以 git stash 正在进行的 merge 吗?

标签 git merge git-stash

我正在解决 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/

相关文章:

c# - 查看 TortoiseGit 生成的 git 命令

git merge ,保留两者

git - 您可以从 GitHub 上的命令行发出 pull 请求吗?

xcode - 如何在 Xcode merge 工具中转到下一个冲突?

git - "git pull"可以自动存储和 pop 挂起的更改吗?

git - 获取 git stash 父提交

git - 如果rstudio如何从git选项卡中获取文件

git - 在 git 中单独 merge 提交的目的是什么?

java - 合并多个 HashMap

Git 存储和工作树问题