git reset soft mixed 實戰

           --soft
               Does not touch the index file or the working tree at all (but resets the head to <commit>, just like all modes do). This
               leaves all your changed files "Changes to be committed", as git status would put it.

           --mixed
               Resets the index but not the working tree (i.e., the changed files are preserved but not marked for commit) and reports
               what has not been updated. This is the default action.

修改b.txt,新增b_note.txt 。

現在試着將b.txt的修改和b_note.txt 都合到中間的 b8b3019 這個提交。

使用 git reset --soft HEAD^後 git status :

      ====》  

注意c.txt 也出現在了暫存區裏了。

如果我們執行的是 git reset --mixed HEAD^ 的話,執行後git status:

     ===》       

小結:

           --soft

工作區、INDEX 的修改分別保留在工作區和INDEX

當前提交和和目標提交之間的修改出現在INDEX

           --mixed

工作區的修改保留在工作區

INDEX的修改出現在工作區

當前提交和和目標提交之間的修改出現在工作區

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章