Answer the question
In order to leave comments, you need to log in
What is the difference between git reset and git reset --soft?
I have a master branch with several commits:
* 1f52e4c 2018-02-20 | w3 (HEAD -> master) [zlodiak]
* 19299b6 2018-02-20 | w2 [zlodiak]
* ec499c2 2018-02-20 | w1 [zlodiak]
* fcbc61d 2018-02-20 | q1 [zlodiak]
* aae9725 2018-02-19 | cherry -1 [zlodiak]
* 5e5f31e 2018-02-19 | f [zlodiak]
|\
| * 84611db 2018-02-19 | 5 [zlodiak]
| * 175f012 2018-02-19 | 2 [zlodiak]
* | 9f8fb98 2018-02-19 | 6 [zlodiak]
* | f25a332 2018-02-19 | 3 [zlodiak]
|/
* 408d717 2018-02-19 | 1 [zlodiak]
* 710b3ba 2018-02-19 | 0 [zlodiak]
[email protected] /var/www/html/misc/tag $ git reset ec499c2
Unstaged changes after reset:
M index.html
[email protected] /var/www/html/misc/tag $ git log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short --all
* ec499c2 2018-02-20 | w1 (HEAD -> master) [zlodiak]
* fcbc61d 2018-02-20 | q1 [zlodiak]
* aae9725 2018-02-19 | cherry -1 [zlodiak]
* 5e5f31e 2018-02-19 | f [zlodiak]
|\
| * 84611db 2018-02-19 | 5 [zlodiak]
| * 175f012 2018-02-19 | 2 [zlodiak]
* | 9f8fb98 2018-02-19 | 6 [zlodiak]
* | f25a332 2018-02-19 | 3 [zlodiak]
|/
* 408d717 2018-02-19 | 1 [zlodiak]
* 710b3ba 2018-02-19 | 0 [zlodiak]
Answer the question
In order to leave comments, you need to log in
--soft resets the commit as if a git add was done on the files
--mixed resets the commit as if there was no git add on those files, that's the default.
--hard resets the commit and removes the changes. But, a commit is available by its hash unless it's removed by gc
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question