How to view Git commit history
· Category: Git
Short answer
Use git log to display the commit history of the current branch.
Steps
- View basic commit history:
git log
- View compact one-line history:
git log --oneline
- View graphical history:
git log --oneline --graph --all
- View file-specific history:
git log --follow -- filename.txt
Tips
git log --statshows changed files and insertion/deletion counts.git log -pshows the actual diff for each commit.git log --author="name"filters by author.
Common issues
- Very large history: use
--max-count=20to limit output. - Merge commits cluttering the view: use
--first-parentto follow only the main line.