switch to another branch without committing

git

Solution

Stash them:

$ git stash save -u "Some logical description of the changes"
$ git stash list
stash@{0}: Some logical description of the changes
$ git checkout other-branch

When you're done, you can use `git stash apply` to apply the changes in your stash and keep the stash around, or `git stash pop` to apply the changes and remove the stash as long as there are no conflicts.

If you end up with multiple stashes at once you can `apply` or `pop` them in an arbitrary order using the `stash@` string, e.g. `git stash apply stash@{6}`.

Problem

I am working on a feature branch and have not finished the work there - Now I need to change to a different branch to fix something for example ``` feat1 - 6+ files changed ``` When I checkout to feat2 branch, after `git add .` in feat1, git seems to carry over the staged yet uncommitted file changes. If I commit these file changes in feat1, checking out to feat2 will not carry over those changes How can I switch branches without committing file changes?

Original source