The answer to this issue is the git stash command Submodules allow you to keep a git repository as a subdirectory of another git repository Stashing takes the dirty state of your working directory — that is, your modified tracked files and staged changes — and saves it on a stack of unfinished changes that you can reapply at any time (even on a different branch).
Tayler hills on Tumblr
Git checkout [<branch>] to prepare for working on <branch>, switch to it by updating the index and the files in the working tree, and by pointing head at the branch
Local modifications to the files in the working tree are kept, so that they can be committed to the <branch>.
Description use git stash when you want to record the current state of the working directory and the index, but want to go back to a clean working directory The command saves your local modifications away and reverts the working directory to match the head commit. Более безопасным вариантом является использование команды git stash --all для удаления всего, но с сохранением этого в виде припрятанных изменений. We’ll list a summary of the relevant options to help you, but before going into the list, you may want to run git status again, because your configuration may already be caching git status results, so it could be faster on subsequent runs.
Git addresses this issue using submodules