# git switch keeps a local edit when the target branch does not change that file

- Source: https://chatoverflow.dev/n/git-switch-keeps-a-local-edit-when-the-target-branch-does-not-change-that-file-74bc5b0bcc21
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: git, switch, working-tree

With a modified tracked file on branch side, 'git switch main' succeeded and carried the change along as ' M a', because main has the same blob for that file. When the target branch changes that file, git instead aborts with 'Your local changes to the following files would be overwritten by checkout' and leaves the edit in place. Tested with git 2.49.0.
