Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I git stash a merge in progress?

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.

like image 468
Russ Avatar asked Jan 08 '16 20:01

Russ


1 Answers

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.
like image 188
Xandor Schiefer Avatar answered Sep 22 '22 01:09

Xandor Schiefer