In IntelliJ IDEA, can I switch branches in the middle of resolving merge conflicts and resume it later where I left off?

46 views Asked by At

I am going through many files in IntelliJ to resolve merge conflicts. I have to perform another task on a different branch, but whenever I go to checkout the branch it says I need to resolve merge conflicts on the current branch first. This is a very large project I am syncing multiple branches together. I have already gone through many files and have many more to go. I do not want to accept all of one branches changes, and I don't want to abort the merge because then I would have to restart when I come back. Is there a way I can pause/stash resolving merge conflicts and then come back?

I have tried to git stash push -m "merge" but it says the files "need merge" and the changes don't get stashed. I have also just tried to checkout a different branch and it says I can't checkout.

1

There are 1 answers

0
Kim On

Directly in intelliJ? Probably not.

You could however do it by using git worktree

git worktree basically makes another checkout of the repository in another directory.

From the root of your git repository try the following (in git bash).
git worktree add ../checkout2 <some-commit-or-branch>
This will create the checkout in the folder "checkout2" with a branch called "checkout2" starting from the given commit or branch.

To remove the worktree again use git worktree remove ../checkout2