To demonstrate branches, I’m going to add another page to the website project. This will be an introduction page called 01-intro.html.
This new page will be added to the project on a new branch. Currently we only have the master branch and everything we’ve done so far has been done on this master branch.
This is easy. Just click the small arrow to the right of the master branch in the left hand file tree and select Figure 6.44):(
This opens the Create new branch dialogue box:
If we had more than one branch, we could choose which branch to split from (master branch and that’s all we can choose.). In our case we only have the
Enter the name for the new branch; call it d-01-intro.
Brackets will automatically switch to the new branch (Figure 6.46).
I’ve highlighted the new branch in the file tree (highlighted in orange). Notice also, that although we are on a new branch, nothing has changed, Brackets is still reporting Nothing to commit, working directory clean.
The workflow diagram now has a branch—woohoo (These diagrams are now reminding me of the opening sequence to Dad’s Army):
Make sure the new branch is selected (d-01-intro is showing as the active branch in the file tree).
Now add a new file (just as we did before in § 6.2). Right click the file tree select and rename the file 01-intro.html.
Add the following code to it.
<html lang="en"> <!-- Declare language --> <head> <!-- Start of head section --> <meta charset="utf-8"> <!-- Use Unicode character set --> <link rel="stylesheet" type="text/css" href="11-resources/01-css/style.css"> <title>PracticalSeries: Git Lab - Introduction</title> </head> <body> <h1>A Practical Series Website</h1> <h3>Introduction</h3> <p>This page is an introduction to the website and how to use it.</p> </body> </html>
|Code 6.6 d-01-intro branch—01-intro.html new file|
This will show as untracked in the Git pane. Tick the box, click and enter the following commit message:
D: Incremental Build - 01-intro page
I get commit [e14911e].
Give the commit the tag d-P01-01.01 and we’re done.
This is what I have in Brackets (commit history view):
And the workflow is now: