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

后端 未结 15 1222
野的像风
野的像风 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:06

    All the other answers are great, but I find it best to understand them by breaking down files into three categories: unstaged, staged, commit:

    • --hard should be easy to understand, it restores everything
    • --mixed (default) :
      1. unstaged files: don't change
      2. staged files: move to unstaged
      3. commit files: move to unstaged
    • --soft:
      1. unstaged files: don't change
      2. staged files: dont' change
      3. commit files: move to staged

    In summary:

    • --soft option will move everything (except unstaged files) into staging area
    • --mixed option will move everything into unstaged area

提交回复
热议问题