git allows you to switch between branches even if you have uncommitted changes in the current branch. Files remain uncommitted and you can transfer them to another branch if you need to. This is great when you realize that you have done work on feature/feature1 , which should be on feature/feature2 .
After you make the changes, they no longer switch between branches. Then you can combine or change the cherry between the branches.
Please note that git will not allow you to switch between branches if you have uncommitted changes that cause merge conflicts in the branch you want to switch to, and possibly even if one of your changes is in the file that was changed and passed to the branch you want to go to. In this case, you first need to commit, revert, or reschedule your changes.
If git does not allow you to switch between branches, and you are trying to resolve this by putting your changes before switching branches, you must make sure that you are nested in the original branch. If you are on feature/feature1 , discard changes, then switch to feature/feature2 and put there, you will lose the changes that were present in feature/feature2 , but not in feature/feature1 . This is hard to detect.
Arjan
source share