The store’s site has a history now. Two commits hold the site as it arrived and the removal of the handmade copies. The .gitignore keeps the Wi-Fi password out, and the check script reports every check as passed. That leaves the to-do list in the README, which the previous developer wrote and then left for you, along with the job of working through it.
From here on, every change you make to the site goes into a commit. In this lesson, you’ll make two unrelated changes, decide which files belong together, and record each change as a commit of its own, with a message that tells a future reader why it happened. Start with the work itself, and then see what Git makes of it.
Decide What Belongs Together
When you edit several files in one sitting, Git doesn’t know which edits belong together, so that’s a decision you make before you commit. To see why it matters, you need a few real changes. The last item on the README’s To do list is a good one to start with:
README.md
- [ ] The phone number in the footer is old. The new one is (555) 014-2290.
The footer is part of every page, and each of the four HTML files has its own copy of it. To find every place where the old number appears, open VS Code’s search panel with Ctrl+Shift+F, or Cmd+Shift+F on macOS, and search for 7731, the last four digits of the old number.
You get one line in each of index.html, deals.html, departments.html, and pickup.html, and the number shows up twice in each of those lines. One is the tel: address that a phone dials when someone taps the link, and the other is the number people read. Change both of them so that the link in every footer looks like this:
index.html
<a href="tel:+15550142290">(555) 014-2290</a>
Save all four files. Before you commit anything, check that the change works on the site. Right-click index.html, choose Open in Integrated Browser, and visit each page from the navigation: Home, Weekly deals, Departments, and Curbside pickup. Every footer should read (555) 014-2290. If one still shows the old number, check that its file has both edits and that you saved it.
Leave the to-do’s checkbox unticked for now, even though the number is in place. You’re about to edit the README for a different reason, and ticking the box in the same file would tie the two changes together. You’ll see why that matters in a moment.
While the README is open, take a look at its Where things are table. It lists the project’s files, but the .gitignore you wrote in the last lesson is missing, because the table is older than that file. Add a row for it at the end of the table, and save the README:
README.md
| `.gitignore` | Keeps files such as `notes.txt` out of Git |
Both changes are now saved in your files, but Git hasn’t recorded either of them. Ask Git what it sees:
$ git status
On branch main
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: README.md
modified: deals.html
modified: departments.html
modified: index.html
modified: pickup.html
no changes added to commit (use "git add" and/or "git commit -a")
Five files are modified. You could stage them all with git add . and make one commit, and Git would accept it. Before you do, think about the history that would give you. Someone who later wants to know when the phone number changed would find a commit that also edits the README. And if the new number turned out to be wrong, undoing that commit would take the README row with it.