Help, I can't switch branches because of my local changes
Git will not switch while your uncommitted work would be lost. Put it aside, switch, and bring it back later.
git switch main error: Your local changes to the following files would be overwritten by checkout: index.html Please commit your changes or stash them before you switch branches. Aborting
The fix
git stashPuts your uncommitted changes on a shelf. The working tree is clean now.
git switch mainThe switch works now.
git switch feature/loginLater, back on your own branch …
git stash pop… take the changes off the shelf again.
main is an example. Replace it with your own.
Why this works
Switching branches rewrites your files, and Git refuses to do that when it would destroy edits that exist nowhere else. git stash moves those edits onto a shelf and leaves a clean working tree. Plain git stash only takes tracked files: if Git complains about untracked files instead, use git stash -u. Popping on a different branch can conflict; Git then keeps the stash, so nothing is lost.