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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With