我有一个主分支到我提交最后一次更改的地方,然后在我运行之后
git branch test
git checkout test
我删除了项目文件夹中的文件README
然后我跑了
git checkout master
现在没有README文件了。
我认为当你创建一个新分支时,就像创建一个新提交一样。我究竟做错了什么?
Creating a branch is not like creating a new commit. Creating a branch is like creating an easy to read reference to a commit hash.
So by being on the master
branch and then going:
git branch test
git checkout test
rm README
git checkout master
You will still have unstaged changes on the master
branch, because you didn't actually do anything to test
.
If you do git status
you should have README missing.
You can get it back by doing git checkout README
.