What's the difference between git reset --mixed, --soft, and --hard?

后端 未结 15 1587
野的像风
野的像风 2020-11-22 14:39

I\'m looking to split a commit up and not sure which reset option to use.

I was looking at the page In plain English, what does "git reset" do?, but I real

15条回答
  •  南方客
    南方客 (楼主)
    2020-11-22 15:12

    Before going into these three option one must understand 3 things.

    1) History/HEAD

    2) Stage/index

    3) Working directory

    reset --soft : History changed, HEAD changed, Working directory is not changed.

    reset --mixed : History changed, HEAD changed, Working directory changed with unstaged data.

    reset --hard : History changed, HEAD changed, Working directory is changed with lost data.

    It is always safe to go with Git --soft. One should use other option in complex requirement.

提交回复
热议问题