Your First Repository

Four commands and you have a tracked project.

git init starts tracking this directory.

git status says what git currently believes.

git add file stages a change.

git commit -m "message" records it.

✦ status is the command to lean on

Run it before adding, after adding, and before committing. It is not a formality, it is the only command that tells you what git thinks AND what to do next. Almost every confusing git situation is one where somebody stopped checking status and started guessing.

SANKOFA SANDBOX
A portfolio site is waiting in ~/portfolio. It is not tracked by anything yet.
Type `cd portfolio` to begin.
learner:~$

Git here is simulated, but init, status, add, commit, log, diff, branch, merge, remote and push all behave properly, including the errors.

Try it → Run `cd portfolio`, then `git status` and read the refusal. Then `git init`, then `git status` again. Watch the same command go from an error to a useful answer.

Reading the status output. Files fall into groups, and the group is the whole message.

Untracked means git has never seen this file.

Changes to be committed means staged and ready.

Changes not staged for commit means edited since the last commit, but not yet staged.

When you are confused about what git is doing, you are almost always confused about which of these a file is in.

◈ Graded Task

Start tracking the portfolio. Move into the portfolio directory, initialize a repository there, stage the two HTML files and the stylesheet, and make a first commit with the message Add portfolio pages.

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

SANKOFA SANDBOX
learner:~$

Mark this lesson complete

Signed in, your progress follows you to every device.

Next: Practice Test →
← Back