Practical uses of git reset --soft?

后端 未结 11 2024
被撕碎了的回忆
被撕碎了的回忆 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:35

    Another potential use is as an alternative to stashing (which some people don't like, see e.g. https://codingkilledthecat.wordpress.com/2012/04/27/git-stash-pop-considered-harmful/).

    For example, if I'm working on a branch and need to fix something urgently on master, I can just do:

    git commit -am "In progress."
    

    then checkout master and do the fix. When I'm done, I return to my branch and do

    git reset --soft HEAD~1
    

    to continue working where I left off.

提交回复
热议问题