2

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

2 Answers 2

1

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.

2
  • 1
    to unstash chnage I can run, git stash apply? Commented Nov 1, 2022 at 13:56
  • yes, apply will apply the stash. But it will not remove the stash. So if you will not need the stash again use "git stash pop"
    – sanurah
    Commented Nov 1, 2022 at 13:58
0

An alternative solution for fast branch switching could be to use a tool that automates git for you.

One of those is for instance HighFlux which manages your branch for you and makes switching instant without having to stash.

Another option is Gitless which also keeps track of your working changes together with the branch so that switching doesn't require stash.

Not the answer you're looking for? Browse other questions tagged or ask your own question.