Git error when switching branches: Your local changes to the following files would be overwritten by checkout

Problem:

reason:
the branch is switched between the staging area and the local warehouse before the changed file is submitted.

Solution: execute the following commands in turn

git add filename (with suffix) # commit the changed file to the staging area
git commit -m "Changed files" filename (with suffix) # Commit the changed files to the local repository

Read More: