Useful Git Commands You Should Know
A collection of essential Git commands to streamline your version control workflow.
List all files (excluding node_modules and .next)
Get a tree-like view of your project structure without the clutter:
find . -not -path "./node_modules*" -not -path "./.next*" -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'Condensed commit history
See your commit history in a compact one-line format:
git log --onelineView all branches at a glance
List both local and remote branches in one command:
git branch -aInspect recent changes
See what files were modified in the last commit:
git show --name-onlyTrace changes to a specific file
Find all commits that affected a particular file:
git log -- filenameSearch across your codebase
Find text patterns in all tracked files:
git grep "pattern"Quick status check
See your current branch and changes at any time:
git statusDetailed recent activity
View the last 5 commits with file change statistics:
git log -5 --stat💡 Pro-tip: Add
--graphto visualize branch history.