22

What does 'git reset' command will do without any other option? Will it reset the staging index with the head?

Mohan P
  • 389
  • 1
  • 5
  • 11

2 Answers2

15

Exactly.

Without option, "git reset" is interpreted as "git reset --mixed HEAD".

git reset has three modes: soft, mixed, and hard (the default is "mixed").

Like many other git commands, git reset takes an argument which is a reference to a commit (a branch name, a tag name, a commit SHA, a relative reference like HEAD~2). By default, if no reference is specified, HEAD is used.

I suggest you read the last blog entry of "Progit", which explains in detail the "git reset" command: http://git-scm.com/book/en/v2/Git-Tools-Reset-Demystified

Sz.
  • 3,342
  • 1
  • 30
  • 43
Benoit Courtine
  • 7,014
  • 31
  • 42
  • Edited: the old link (http://progit.org/2011/07/11/reset.html) is no longer available. Its apparent successor page says: "Moved! Technical content that was previously found in the blog section of this site has been integrated into the second edition of the Pro Git book." So, linked the related page from that instead. (The old blog post can be found at archive.org though; I'm basically writing this comment to still keep the old link around for that purpose.) – Sz. Feb 02 '22 at 01:48
2

Have a look at my answers here: "git rm --cached x" vs "git reset head -- x"?

here: What's the difference between git reset file and git checkout file?

and here: Why are there 2 ways to unstage a file in git?

And use the search as well.

Community
  • 1
  • 1
manojlds
  • 290,304
  • 63
  • 469
  • 417