Silkking
Silkking

Reputation: 270

Gitkraken problem: 1 file to stash on merge

I'm trying to merge two branches. First, I made a pull. When I clicked on the merge button, it threw an error saying that there is one file (just one file) that has been deleted and needs to be treated.

After I stash it and commit it, I tried to merge again, but it threw the same error again, but with a different file (also one file).

The major problem of this is that I can't switch branches, so I can't recover the code I've made in the other branch.

Don't know what can I upload here to be more helpful, but I'll see what I can do if you ask me for something.

Thanks

Upvotes: 0

Views: 594

Answers (1)

CodeWizard
CodeWizard

Reputation: 142522

The major problem of this is that I can't switch branches, so I can't recover the code I've made in the other branch.

You can use git worktree instead of working on a single folder, in your words, This will allow you to switch branches

git worktree

What is worktree?

worktree allows you to have multiple instances of the same repository across different folders.

git worktree add <second path>

will create another folder on your computer which allows you to work on different branch simultaneously in which you can install your npm and you don't need to remove/switch to a different branch.

enter image description here

git worktree will create a new working folder allow us to work on multiple branches on the same time. each copy will point to the origin repository while the 3-states is a new and fresh copy. This save us the need to use git stash or even to clone a new repository since those worktree shares the same repo we can checkout any branch on any worktree, we can do a cherry-pick or merge and all will be done locally on our machine.

This will allow you do to any experiments on the new worktree without having any effect on the repository itself.
In the attached image you can see that there are 2 separate working folder but both of them are using a single repo and share the content.

enter image description here

Upvotes: 1

Related Questions