Git command snippets
Copy-paste-ready Git commands for branching, merging, reverting, stashing, and log inspection.
Git command snippets
Copy-paste-ready Git commands for branching, merging, reverting, stashing, and log inspection.
View a Condensed Git Commit History
git log shows a one-line-per-commit view with branch graph:
git log --oneline --graph --allDiscard All Uncommitted Changes in Git
git checkout restores all files to the last committed state:
git checkout -- .Stash Uncommitted Changes in Git
git stash saves work in progress without committing:
git stash
git stash popShow Files Changed in the Last Git Commit
git show lists files modified in the most recent commit:
git show --stat HEADFind Which Git Commit Introduced a Bug
git bisect performs a binary search through commit history:
git bisect start
git bisect bad HEAD
git bisect good abc1234Delete a Local Git Branch
git branch removes a merged branch:
git branch -d feature/old-branchDelete a Remote Git Branch
git push removes a branch from the remote:
git push origin --delete feature/old-branchShow the Current Git Branch Name
git branch displays the active branch:
git branch --show-current