I have a master branch to where I had commited my last change and then after I ran
git branch test
git checkout test
I deleted file README in the project folder
then I ran
git checkout master
Now there is no README file anymore.
I thought that when you create a new branch it's just like creating a new commit. What am I doing wrong?
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
.