Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does 'git reset' command do without any option?

Tags:

git

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

like image 392
Mohan P Avatar asked Aug 03 '11 18:08

Mohan P


People also ask

What does git reset actually do?

To review, git reset is a powerful command that is used to undo local changes to the state of a Git repo. Git reset operates on "The Three Trees of Git". These trees are the Commit History ( HEAD ), the Staging Index, and the Working Directory.

Will git reset delete files?

Running git reset will typically delete files and commits. And without those, you don't have a project! This is why it's critical to plan ahead when using it, so you don't end up deleting elements that are critical for your project.

Does git reset keep changes?

Git Reset A Specific FileThe changes it contains will still be present in the working directory. The --soft , --mixed , and --hard flags do not have any effect on the file-level version of git reset , as the staged snapshot is always updated, and the working directory is never updated.

How do I completely reset git?

To hard reset files to HEAD on Git, use the “git reset” command with the “–hard” option and specify the HEAD. The purpose of the “git reset” command is to move the current HEAD to the commit specified (in this case, the HEAD itself, one commit before HEAD and so on).


2 Answers

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

like image 152
Benoit Courtine Avatar answered Oct 14 '22 08:10

Benoit Courtine


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.

like image 33
manojlds Avatar answered Oct 14 '22 07:10

manojlds