Snippets / Tags
git
8 git code snippets across 1 language. Copy-paste solutions from production code.
8
snippets
git
8 snippetsBeautiful One-Line git log as a Global Alias
Set up a global git alias for a colored, graph-aware, one-line git log that makes commit history actually readable.
Find the Bad Commit with git bisect
Use git bisect to binary-search through commits and find the exact one that introduced a bug or test failure.
Recover a Deleted Git Branch with reflog
Use git reflog to find and restore a branch you accidentally deleted with git branch -D or a botched rebase.
Remove Untracked Files Safely with git clean
Use git clean -n to preview what will be deleted, then -fd to actually remove untracked files and empty directories. Without losing work.
Squash the Last N Commits with Interactive Rebase
Use git rebase -i to squash, reorder, edit, or drop the last N commits before pushing or opening a pull request.
Undo the Last Git Commit (Keep or Discard Changes)
How to undo the most recent git commit using git reset, with --soft, --mixed, and --hard explained side by side.
Useful git stash Patterns Beyond stash and pop
Stash with a message, stash untracked files, list stashes, apply a specific stash, and stash a single file. The full git stash workflow.
Work on Multiple Branches with git worktree
Use git worktree to check out multiple branches simultaneously in separate directories. No more stash-and-switch dance.