Skip to main content
  1. Learn
  2. Software Development
  3. Guides
  4. Git tutorial
  5. Git collaboration
  6. Switching branches
  7. Stashing branches
GuidesSoftware DevelopmentBacklog

Project and code management together.

Stashing branches

If you have uncommitted changes (or new files added) in your working tree and you want to switch to a new branch, those uncommitted changes will also carry to the new branch. Changes that you commit will be committed to the new branch.

However, if Git finds a conflict between the uncommitted changes in your current branch and the files in the new branch you’re switching to, you will not be allowed to switch. You must commit or stash those changes before switching branches.

You can think of stash as a drawer for temporarily storing uncommitted changes. Stashing allows you to put aside any “messy” changes in your working tree and continue working on a new branch with a clean slate.

You can always take out uncommitted changes stored in the stash and apply them to the original branch and other branches later.

Subscribe to our newsletter

Learn with Nulab to bring your best ideas to life