Git
Setup aliases
git config --global --edit
Reset last commit (keep changes staged)
Reset last commit (keep changes unstaged)
Reset last commit (discard all changes)
Revert last commit
Revert specific commit
Revert without auto-commit
git revert -n <commit-hash>
Standard merge
git checkout main
git merge feature
Squash merge
git checkout main
git merge --squash feature
git commit -m "Add feature (squashed)"
Rebase and merge
git checkout feature
git rebase main
git checkout main
git merge feature
Stash all changes
Stash with name
git stash save "work in progress on header"
List stashes
Apply stash (keep in list)
Apply stash (remove from list)
Stash specific files
Show what would be deleted
Remove untracked files
Remove untracked files and directories
Untrack file (keep on disk)
git rm --cached <filename>
Untrack folder (keep on disk)
git rm -r --cached <folder>
Remove .git folder (Linux/macOS)
Remove .git folder (Windows PowerShell)
Remove-Item -Recurse -Force .git
Remove .git folder (Windows CMD)
Abort merge
Prune remote branches
Create tag
Delete remote tag
git push origin --delete tag v2.0
Pull with rebase
Delete local branch
git branch -d <branch-name>
Delete remote branch
git push origin --delete <branch-name>