Back to IntelSOURCE: gist
Git Cheatsheet: From Basics to Time Travel
Git Cheatsheet: From Basics to Time Travel
A collection of essential Git commands, from daily workflows to digging through the depths of your repository's history.
🔍 Searching History
Find when a file existed (even if deleted)
DATA_NODE: bash
git log --all -- [path]Search for content changes (Pickaxe)
Find commits where a specific string was added or removed:
DATA_NODE: bash
git log -S "your_search_string"Search content with Regex
DATA_NODE: bash
git log -G "your_regex"Find a file in any commit/branch
DATA_NODE: bash
git rev-list --all | xargs git grep -l "filename"See the history of a specific function/method
DATA_NODE: bash
git log -L :function_name:file_path🚀 Daily Workflow
Stage and Commit
DATA_NODE: bash
git add . git commit -m "feat: descriptive message"Undo last commit (keep changes)
DATA_NODE: bash
git reset --soft HEAD~1Fix the last commit message
DATA_NODE: bash
git commit --amend -m "new message"🌿 Branching & Merging
Switch to a new branch
DATA_NODE: bash
git checkout -b feature/cool-stuff # or the newer way: git switch -c feature/cool-stuffList all branches (including remote)
DATA_NODE: bash
git branch -aSafely delete a branch
DATA_NODE: bash
git branch -d branch_name🛠️ Cleanup & Maintenance
Discard all local changes
DATA_NODE: bash
git reset --hard HEADClean untracked files
DATA_NODE: bash
git clean -fdStash changes for later
DATA_NODE: bash
git stash save "Work in progress" git stash list git stash pop📤 Remote Operations
Update local with remote and rebase
DATA_NODE: bash
git pull --rebase origin mainPrune old remote tracking branches
DATA_NODE: bash
git fetch -p// INTEL_SPECIFICATIONS
Dated08/01/2026
Process_Time2 Min
Categorygist