Home > Back-end >  Git switch branch without losing changes
Git switch branch without losing changes

Time:11-01

I'm working on a project using Git for versioning. I'm now working on a feature in a different branch. I have not completed my changes but I need to switch to a different branch from master branch. I have tried to stash my changes with

git stash

But it's not stashing my changes.

I checked with

git stash list 
git status

CodePudding user response:

I assume you have untracked files. By default, git stash the uncommitted changes(staged and un-staged files) and overlooks untracked and ignored files. you can add them for tracking,

git add .

or you can force stash or include untracked files like below,

git stash -u
git stash --include-untracked

if it doesn't help please show the output of "git status" command.

  •  Tags:  
  • git
  • Related