CodeBlanks Logo Icon CodeBlanks

Summary - Viewing history

Combine show and log options to research the history.

History inspection tools summary

With git show, you inspect the details and patch diff of a single commit. Meanwhile, git log lets you search history using --author, --since, and file filters. For renamed files, you rely on the --follow flag to keep tracking history.

git show -s HEAD
git log --author="Ece" --oneline
git log --follow -- ayar.json

Using these tools together lets you effortlessly trace any change across the project.

Practice Combine author and file filter

Run git log with --author="Ece", --format="%s", and -- modul_a.py to list the matching commit subject.

Starter code

terminal
git init -q
git config user.name "Ece"
git config user.email "ece@example.com"
echo "modul a" > modul_a.py
git add modul_a.py
git commit -qm "Modul A hazirlandi"

git config user.name "Can"
git config user.email "can@example.com"
echo "modul b" > modul_b.py
git add modul_b.py
git commit -qm "Modul B hazirlandi"

git config user.name "Ece"
git config user.email "ece@example.com"
echo "modul c" > modul_c.py
git add modul_c.py
git commit -qm "Modul C hazirlandi"

# Ece tarafindan yapilan modul_a.py commit'ini listele

Sample solution

terminal
git init -q
git config user.name "Ece"
git config user.email "ece@example.com"
echo "modul a" > modul_a.py
git add modul_a.py
git commit -qm "Modul A hazirlandi"

git config user.name "Can"
git config user.email "can@example.com"
echo "modul b" > modul_b.py
git add modul_b.py
git commit -qm "Modul B hazirlandi"

git config user.name "Ece"
git config user.email "ece@example.com"
echo "modul c" > modul_c.py
git add modul_c.py
git commit -qm "Modul C hazirlandi"

git log --author="Ece" --format="%s" -- modul_a.py

Expected output

Modul A hazirlandi

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Which pair of commands is used to search history by author and inspect the diff of the latest commit?

  • git config and git init
  • git log --author and git show Correct answer
  • git status and git diff
  • git rm and git commit

Explanation: git log --author is used to filter history by author, and git show displays the detail and patch of the commit.

2 View commit summary

Question
git ____ -s HEAD
Answer
git show -s HEAD

Explanation: git show -s HEAD suppresses the diff patch and prints only the latest commit metadata.

3 History commands match

Term Meaning
git show Shows commit detail and patch
--follow Tracks previous file names
--author Filters by author info
--since Filters by date range

All lessons in Beginner