Practical uses of git reset --soft?

后端 未结 11 2026
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 16:24

I have been working with git for just over a month. Indeed I have used reset for the first time only yesterday, but the soft reset still doesn\'t make much sense to me.

11条回答
  •  再見小時候
    2020-11-22 16:54

    One practical use is if you have committed to your local repo already (ie. git commit -m ) then you can reverse that last commit by doing git reset --soft HEAD~1

    Also for your knowledge, if you have staged your changes already (ie with git add .) then you can reverse the staging by doing git reset --mixed HEAD or i've commonly also just used git reset

    lastly, git reset --hard wipes everything out including your local changes. The ~ after head tells you how many commits to go to from the top.

提交回复
热议问题