撿寶 git cherry-pick
情境
- 新增 want
touch want
- 修改 want
echo happy > want
- 刪掉 want
git rm want
歷史如下
git log --oneline --name-status
撿 modify want
git cherry-pick -n 941ab3b
若撿到衝突 unmerged path
git status
後續有幾種選擇
- 讓 want staged,這個例子
cat want
應該有happy
git add want
- 把 want 變成 HEAD 狀態,在這個例子就是 D (刪除)
git reset want
- 把 want 變成別的 commit 狀態,這個例子
cat want
應該要是空的git add want git checkout 2d8880e -- want