0

I was working in a branch that I created like:

git checkout -b feature_xyz

After working in that branch, I wanted to throw away all the work so I moved back to master:

git checkout master

When I did that, I saw this:

M app/path/to/file1.rb M app/path/to/file2.rb D app/path/to/file3.rb switched to branch 'master' your branch is up-to-date with origin/master

I then deleted the feature branch:

git branch -d feature_xyz

Now when I do git status I see files that I was modifying in that feauture_xyz branch, how is this possible?

Blankman
  • 259,732
  • 324
  • 769
  • 1,199

1 Answers1

2

Git is intended to work like this. Uncommitted changes get carried from branch to branch as you switch, if they can be.

See Git - checkout another branch when there are uncommitted changes on the current branch for more information.

Community
  • 1
  • 1
torek
  • 448,244
  • 59
  • 642
  • 775
  • so next time as long as I commit then it is fine right? I mean that is what I have been doing w/o issue before. – Blankman Jul 21 '16 at 02:34
  • Yes, once they are added-and-committed, Git knows you don't intend to carry the changed files around with every new `git checkout`. – torek Jul 21 '16 at 02:56