Git Commands & Workflow Reference
Essential commands for branching, stashing, rebasing, undoing changes, and history inspection
Branching & Switching
Create and switch to new branch
git switch -c feature/my-featureList local & remote branches
git branch -aDelete local branch safely
git branch -d feature/branch-nameForce delete local branch
git branch -D feature/branch-nameStashing & Temporary Storage
Stash uncommitted changes with message
git stash push -m 'WIP: auth integration'Apply latest stash & keep in stash list
git stash applyApply latest stash & remove from list
git stash popList all stored stashes
git stash listUndoing & Recovering Changes
Undo last commit (keep changes staged)
git reset --soft HEAD~1Undo last commit (keep changes unstaged)
git reset HEAD~1Discard unstaged changes in a file
git restore path/to/fileRevert a public commit with a new commit
git revert <commit-sha>View reflog to rescue lost commits
git reflogRebasing & History
Interactive rebase last N commits
git rebase -i HEAD~4Rebase current branch on main
git fetch origin && git rebase origin/mainOne-line pretty commit log graph
git log --oneline --graph --decorate --all