GIT :: Switch branch without discarding local changes
Sometimes you modified files in a branch and you need to switch current branch into different branch without committing them. You need to stash them first. $ git checkout develop error: Your local changes to the following files would be overwritten ... Run git stash save, or just plain git stash which is short for save $ git stash save Those are safely stored in the repository. After switch branch and you want will apply them. $ git checkout develop Switched to branch 'develop' $ git stash apply If it is successful you need to delete references to the commits. $ git stash drop But if you apply option does a merge stashed changes. $ git stash apply There may be merge conflicts. All went successfully you can drop stash $ git stash drop git stash pop is short-hand for git stash apply && git stash drop