Code BeautifierDev Tools

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-feature
List local & remote branches
git branch -a
Delete local branch safely
git branch -d feature/branch-name
Force delete local branch
git branch -D feature/branch-name

Stashing & Temporary Storage

Stash uncommitted changes with message
git stash push -m 'WIP: auth integration'
Apply latest stash & keep in stash list
git stash apply
Apply latest stash & remove from list
git stash pop
List all stored stashes
git stash list

Undoing & Recovering Changes

Undo last commit (keep changes staged)
git reset --soft HEAD~1
Undo last commit (keep changes unstaged)
git reset HEAD~1
Discard unstaged changes in a file
git restore path/to/file
Revert a public commit with a new commit
git revert <commit-sha>
View reflog to rescue lost commits
git reflog

Rebasing & History

Interactive rebase last N commits
git rebase -i HEAD~4
Rebase current branch on main
git fetch origin && git rebase origin/main
One-line pretty commit log graph
git log --oneline --graph --decorate --all

Try Related In-Browser Tools