Founding prices until 15 December: 30% off Pro, locked for life. See pricing

$ … error: Your local changes to the following files would be overwritten by checkout

'Your local changes would be overwritten': switch branches safely

Switching or pulling would replace files you changed but haven't committed.

Git

What it means

Git refuses to throw away uncommitted work. You need to commit it, stash it, or discard it first.

Causes and fixes

Most likely first. Run the check, and if it matches, apply the fix.

1. Uncommitted edits to files that differ on the other branch

Check:

git status

Fix: git stash (then git stash pop on the right branch), commit on a branch, or git restore <file> to discard.

Fix it yourself

A live machine in your browser with this problem already on it. The grader checks the result.

Open the lab

No account needed for your first tries.