Skip to content

Allow switching branches with pending changes but "no action" #2204

@Danielku15

Description

@Danielku15

Fork allows branch switching without applying anything to the pending changes. I think it works this way (copied from the Brave search AI summary):

Git switch with uncommitted changes:

  • If the changes in your working directory do not conflict with the target branch (i.e., the files are identical or the changes are in untracked files), Git will allow the switch and preserve your changes in the working tree.
  • If the changes conflict (e.g., a tracked file is modified in both branches), Git will refuse the switch and show an error:
    error: Your local changes to the following files would be overwritten by checkout.

Stashing can force you into a merging state and it happened to me various times that accidentally I lost changes (user error). Most of the time I prefer seeing errors if "clean branch switches" do not work, it tells me I should really first commit/discard/stash the pending changes depending on what the changes are.

Metadata

Metadata

Assignees

Labels

duplicateThis issue or pull request already exists

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions