Commits Worth Reading

One commit, one idea. A commit that fixes a bug, renames a variable, and adds a feature cannot be described in one sentence, cannot be reviewed, and cannot be undone without losing the other two things.

The test is simple: if your message needs the word and, it is probably two commits.

A message that works. Write a short line in the imperative, as if completing the sentence this commit will.

`

Add contact form validation

Fix navigation collapsing on mobile

Remove unused stylesheet

`

Not added stuff, not fixes, not asdf. You are writing to a future colleague, and that colleague is usually you.

✦ Staging is what makes atomic commits possible

You will often finish a session having done three unrelated things. Staging lets you commit them separately: add the files for one idea, commit, add the files for the next, commit again. The mess in your working directory does not have to become a mess in your history.

SANKOFA SANDBOX
learner:~$

Try it → In the portfolio, init a repo, then make TWO separate commits: first stage and commit only styles.css with a message about styling, then stage and commit the HTML files with a message about pages. Then run `git log` and read your own history.

◈ Graded Task

Protect the repository before it is too late. In the portfolio directory, create a .gitignore listing secrets.env and .DS_Store, initialize the repository, then stage and commit everything with the message Add portfolio with ignore rules. The secret must never appear in the commit.

Checked against the filesystem you leave behind, not the commands you type, so any route that gets the job done counts. 5 visible and 3 hidden checks.

SANKOFA SANDBOX
learner:~$

Mark this lesson complete

Signed in, your progress follows you to every device.

Next: Practice Test →
← Back