git reset and git clean, git checkout

Option Command Scope Risk Level Use Case
X git reset --hard HEAD && git clean -fd Working tree + staging + untracked ⭐⭐⭐⭐⭐ Completely wipe all local changes
u git checkout -- . Working tree (unstaged only) ⭐⭐ Discard unstaged changes
c git clean -fd Untracked files/dirs only ⭐⭐⭐ Clean build artifacts, logs, etc.
S git reset HEAD Staging area only Unstage files (keep working changes)
s git reset --soft HEAD Commit history only ⭐⭐ Amend last commit (keep staged changes)
m git reset --mixed HEAD (or git reset) Commit history + staging ⭐⭐ Redo commit from scratch (keep work)
h git reset --hard HEAD Working tree + staging + commit ⭐⭐⭐⭐⭐ Force reset to a clean state
posted @ 2025-12-24 15:01  AI健康  阅读(1)  评论(0)    收藏  举报