Can I git stash a merge in progress?

荒凉一梦 提交于 2021-01-22 00:36:22

问题


I'm in the middle of resolving conflicts for a git merge, but I want to get back to a clean state temporarily without losing the work I've already done on the merge. If I try to git stash, I get errors for each file for which a conflict has not yet been resolved: "needs merge".

Is there a good way to save the merge-in-progress? The only idea that I have is to clone the repo into a different folder, but that seems excessive.


回答1:


You could use the git worktree command to add a new worktree in a different folder. This is like a 2nd index and worktree, but using the same 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.


来源:https://stackoverflow.com/questions/34685407/can-i-git-stash-a-merge-in-progress

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!