Simon Shvets
Simon Shvets

Reputation: 23

Git switch branch without losing changes

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

Upvotes: 2

Views: 124

Answers (2)

Mathijs Vogelzang
Mathijs Vogelzang

Reputation: 558

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.

Upvotes: 0

sanurah
sanurah

Reputation: 1132

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.

Upvotes: 1

Related Questions