ARTICLE DETAIL

资讯详情

深耕网站建设、视觉设计与SEO优化的一线实战洞察。

git reset and git clean, git checkout

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
返回列表