Reputation: 17808
All, I just had a major mishap with git and I'm very confused on what happened/what I did wrong.
I had two files that I've been working on: classA.cpp
and classA.h
. I needed to merge with a coworker. So...
git stash
git pull origin master
Now I have the newest work from my coworker. I get my changes from the stash.
git stash pop
At this point, I'm thinking I should be using git correctly, so I endeavor to make a new branch.
git branch MyChange
git checkout MyChange
git status
Git status shows my two (unstaged) modified files.
git checkout master
git status
Git status shows (again) the two unstaged modified files.
git checkout -- .
Git status shows that the modified files have been rewound.
git checkout MyChange
MODIFIED FILES ARE REWOUND!?!? WHAT THE HECK!?! Where did my thoughts go wrong, I thought changing branches would not affect the other branches.
Upvotes: 0
Views: 43
Reputation: 32731
You did not change the branch, you did change your working tree. And new files / changes that were neither added to the Staging Area nor to a Commit are not tracked and not preserved by git.
Upvotes: 1