is to force checkout a branch
git checkout -f <branch_name>
Force checking out a branch is telling git to drop all changes you've made in the current branch, and checkout out the desired one.
or in case you're checking out a commit
git checkout -f <commit-hash>
"thought that I could change branches without committing. If so, how can I set this up? If not, how do I get out of this problem?"
The answer to that is No, that's literally the philosophy of Git that you keep track of all changes, and that each node (i.e. commit) has to be up-to-date with the latest changes you've made, unless you've made a new commit of course.
Then stash them using
git stash
and then to unstash your changes in the desired branch, use
git stash apply
which will apply you changes but keep them in the stash queue too. If you don't want to keep them in the stash stack, then pop them using
git stash pop
That's the equivalent of apply
and then drop