Practical uses of git reset --soft?

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

    Another use case is when you want to replace the other branch with yours in a pull request, for example, lets say that you have a software with features A, B, C in develop.

    You are developing with the next version and you:

    • Removed feature B

    • Added feature D

    In the process, develop just added hotfixes for feature B.

    You can merge develop into next, but that can be messy sometimes, but you can also use git reset --soft origin/develop and create a commit with your changes and the branch is mergeable without conflicts and keep your changes.

    It turns out that git reset --soft is a handy command. I personally use it a lot to squash commits that dont have "completed work" like "WIP" so when I open the pull request, all my commits are understandable.

提交回复
热议问题