Inspect two commits
git log --oneline --decorate --graph --all
git show --stat HEAD
git diff HEAD~1..HEAD- git log answers where commits are.
- git show answers what one commit contains.
- git diff answers how two states differ.
Read repository history efficiently and compare commits, branches and files using Git object identifiers.
Commits reference parent commits, forming a directed history graph. Branch names are movable references to commits; the commits themselves are addressed by object IDs.
git log summarizes history, git show inspects an object (commonly one commit), and git diff compares content between states. These commands are read-only unless combined with another write operation.
--oneline --graph --decorate --all provides a useful compact graph when branches diverge or merge. Avoid assuming chronological display alone explains ancestry.
git log --oneline --decorate --graph --all
git show --stat HEAD
git diff HEAD~1..HEADGoal: Create three commits and identify exactly which commit changed a line.
mkdir -p ~/gnu-git-labs/module04 && cd ~/gnu-git-labs/module04
git init -b main
git config user.name "GNU Learner"
git config user.email "learner@example.invalid"
printf "port=8080\n" > service.conf
git add service.conf && git commit -m "Add service configuration"printf "port=8081\n" > service.conf
git commit -am "Change service port"
printf "threads=4\n" >> service.conf
git commit -am "Add worker setting"git log --oneline --graph --decorategit show --stat HEAD
git diff HEAD~2..HEADDuring incidents, engineers often inspect what changed between a known-good deployment commit and the current release.
Open each answer only after you have tried to answer the question yourself.
A commit reference that normally moves when new commits are added.
git show.
No; it compares states.