简体   繁体   中英

Git Stashing and Branching

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM