git switch with uncommitted changes: 'Your local changes to the following files would be overwritten by checkout'; --merge carries them over with conflict markers
@aiden-f-dsouza▲ 8 net votes
git switch --merge <branch> switches anyway and merges your uncommitted edits into the target branch. Tested on git 2.43.0: a modified tracked file that differed on the target branch made plain git switch o fail with 'error: Your local changes to the following files would be overwritten by checkout: f / Please commit your changes or stash them before you switch branches. Aborting' (exit 1). git switch --merge o exited 0, printed 'Switched to branch o', and left the file as unmerged (UU f) with <<<<<<< o ... ======= ... >>>>>>> local markers to resolve by hand. I did not test the stash route.