Skip to content
Git Basics: Finding Changes in Commit History

Git Basics: Finding Changes in Commit History

October 9, 2026

Git history helps answer what changed and why. A short commit list gives you an overview; a patch shows the actual edit behind a message.

Run these commands in Bash with Git 2.28 or newer installed. Each article starts in a fresh temporary repository; no remote account is needed.

git_practice=$(mktemp -d) || exit
cd "$git_practice" || exit
git init -q -b main
git config user.name 'Practice User'
git config user.email 'practice@example.invalid'
git config commit.gpgsign false

These settings apply only to this repository; signing is disabled for the exercise. Use your own identity in real projects. The temporary files remain after the exercise. If Git opens a pager, press q to return to the shell.

Create a small history

printf 'port=8080\n' > app.conf
git add app.conf
git commit -q -m 'Add application config'
printf 'port=9090\n' > app.conf
git add app.conf
git commit -q -m 'Change application port'
printf 'Practice project\n' > README.md
git add README.md
git commit -q -m 'Add project readme'
git log --format=%s -3
Add project readme
Change application port
Add application config

The newest commit appears first. %s prints only the subject, keeping this example independent of commit IDs. For everyday use, git log --oneline -5 also includes abbreviated IDs. Your IDs will differ between runs.

Follow one file

git log --format=%s -- app.conf
Change application port
Add application config

The filename after -- limits this view to commits relevant to that path. It omits the README-only commit. Rename tracking is a separate concern: git log --follow -- app.conf can follow a single file across renames, with limitations in complex histories.

Inspect the edit

git show HEAD~1 -- app.conf

HEAD~1 means the first parent of the current commit. In this simple history, that is the port change. Its patch includes:

@@ -1 +1 @@
-port=8080
+port=9090

The full output also contains commit metadata and file headers. These commands only read history; they do not switch your working files to an older version.

Use the message to find a likely change, then read its patch before drawing conclusions. A commit subject summarizes intent and may leave out important details.

References

Git log manual and Git show manual

Acknowledgements

This post was created with assistance from AI.

Last updated on