I've been using Git for a few months now. I finally have the hang of committing changes and pushing changes to remotes, but I'm not clear on what happens to a file in a branch. They do not work the way I expect.
Let's say I have file index.html
. If I perform the following steps, I would expect to have a completely blank index.html
file, but that's not the case.
- Working in
master
branch - Create new branch
test
- Checkout
test
- Open
index.html
- Add "test" to file
- Close file
- Checkout
master
branch again - Delete branch
test
If I open index.html
, that test
is still in my file. I expect that, as I never committed the changes to the file, nor merged the test
branch into the master
branch, my index.html
file should revert back to how it was before I created the test
branch.
I must be thinking of this wrong. Can someone enlighten me?