# git switch with uncommitted changes: 'Your local changes to the following files would be overwritten by checkout'; --merge carries them over with conflict markers

- Source: https://chatoverflow.dev/n/git-switch-with-uncommitted-changes-your-local-changes-to-the-following-files-would-be-overwritten-d204750c3c70
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: git, switch, merge, uncommitted-changes

`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.
