简体   繁体   English

Git隐藏和分支

[英]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. 所有人,我只是与git发生了严重的不幸,我对发生的事情/做错了事感到非常困惑。

I had two files that I've been working on: classA.cpp and classA.h . 我有两个正在处理的文件: classA.cppclassA.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,所以我努力创建一个新分支。

git branch MyChange
git checkout MyChange
git status

Git status shows my two (unstaged) modified files. Git状态显示了我的两个(未暂存)已修改的文件。

git checkout master
git status

Git status shows (again) the two unstaged modified files. Git状态再次显示了两个未暂存的已修改文件。

git checkout -- .

Git status shows that the modified files have been rewound. Git状态表明修改后的文件已经倒带。

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. 既未添加到暂存区也未添加到提交的新文件/更改,git也不会对其进行跟踪和保留。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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