Your daily Git workflow
Read the project history
Use git log to inspect commits and understand how the project reached its current state.
The commit history tells you which snapshots exist and how they connect.
Start with a compact view:
git log --oneline
Each line shows an abbreviated commit ID and its subject. The newest reachable commit appears first.
To see branch and tag names beside their commits, add decorations:
git log --oneline --decorate --graph --all
--all asks Git to start from all local references, not only HEAD. --graph draws the parent relationships. It does not change history.
Inspect one commit
Inspect one commit in detail with:
git show --stat <commit-id>
Then use git show <commit-id> to inspect its patch.
You only need the first few characters of a commit ID. Git accepts any unambiguous prefix.
History is read-only, so these are safe commands when you feel lost. If a change seems to have disappeared after switching or resetting, inspect git log --all before trying another modifying command.
git log follows the current branch by default. If you switched away from a feature branch, its commits might not appear until you add --all or check out that branch again.
Filter history when the list gets long:
git log --oneline -- README.md
That shows only commits that touched README.md. Handy when you want to know who last changed one file.
Another useful filter is by author:
git log --oneline --author="Flavio"
History commands never modify data. Run them freely when you are unsure what happened.
You can also limit how many commits appear:
git log --oneline -5
That is useful on repositories with years of history. Start small, then widen the search when you need more context.
Try this on your own project: find the commit that introduced one file. Read its message, parent, and patch. Can you explain the project state before and after it?
Lesson completed