Inspect The History
Part of the Version Control section of Coddy's Terminal journey. Lesson 27 of 58.
The Cookbook repo now has a small but real history: an initial commit and a follow-up that adds a recipe.
Inspecting the history is the easiest way to confirm the work is in shape. git rev-list --count HEAD walks the history back from the current branch tip and prints how many commits it holds:
git rev-list --count HEADFor the Cookbook repo it prints 2.
To see which files the latest commit holds, list its tree with git ls-tree -r --name-only HEAD. Here it prints .gitignore, index.html, recipes/pasta.md, recipes/pizza.md and style.css: build.log is not there, so the build artifact stayed out of the repo.
Challenge
BeginnerPrint the total number of commits using git rev-list --count HEAD.
Every run starts from a fresh copy of the folder, and the whole script in the editor runs again from the top. Nothing is committed for you: the editor starts with the commands of the previous steps (
git init -q -b main, thegit configlines and the two commits). Keep those lines in the editor. If you clear them you will seefatal: not a git repository.
Try it yourself
git init -q -b main
git config user.name "Cookbook Dev"
git config user.email "dev@coddy.tech"
echo "*.log" > .gitignore
git add .
git commit -q -m "Initial site"
echo "# Pizza" > recipes/pizza.md
git add recipes/pizza.md
git commit -q -m "Add pizza recipe"
# Your commands below
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Version Control
2Getting Started
Initialize A RepositoryThe .git FolderConfigure Your IdentityGit StatusRecap - First Repo8Merging
What Is A MergeFast-Forward MergeThree-Way MergeMerge ConflictsResolve A ConflictRecap - Merge Master11Feature Branch Project
Project OverviewInitialize Main3Tracking Changes
The Staging AreaGit AddGit CommitModifying A Tracked FileGit LogRecap - First Commits6Recipe Site Project
Project OverviewInitialize And IgnorePractice on your own: Terminal playground