6
This is a small but important point.
If I’m on the d-01-intro branch I have these files in the file tree and the following commits:
I clearly have the 01-intro.html file and there are three commits.
Change back to the master branch (by clicking the small arrow next to the branch in the file tree and selecting master, Figure 6.51).
Now I get:
The 01-intro.html file is no longer there and there are only two commits.
To reiterate what I said in section 2.3.1:
SWITCHING BRANCHES CHANGES THE FILES |
This is important. Like I said “you’ll remember it when you’re on the wrong branch wondering where all your files have gone”.
I said before, “you can’t switch branches if you have uncommitted changes on that branch”.
Switch back to the d-01-intro branch and open the 01-intro.html file. Add some text into the <h3>Introduction</h3> line (line 13) and save the file. The file status will now be modified:
If I now try to change back to the master branch I get the following message:
Brackets won’t let you change branches if you have uncommitted changes.
Again this confirms what I said in section 2.3.2:
YOU CANNOT CHANGE BRANCHES IF YOU HAVE |
Always commit changes before switching branches.
See the footnote in § 2.3.2 for the reasons why.
I made the modification to 01-intro.html to prove the above point; I don’t really want to make these changes. However, I’ve saved the file so how do I go back?
The answer is simple, click the
button and select .Click
, the file will go back to how it was and Git will show:Nothing to commit, working directory clean.