Skip to contentSkip to conversation

confusion with some `git reset` commands

DISCUSSION Arup Rakshit 4 participants 4 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hi,

Quoted 1 line

From the command help I see -

[arup@to_do_app]$ git reset -h
usage: git reset [--mixed | --soft | --hard | --merge | --keep] [-q] 
[<commit>]
   or: git reset [-q] <tree-ish> [--] <paths>...
   or: git reset --patch [<tree-ish>] [--] [<paths>...]
    -q, --quiet           be quiet, only report errors
    --mixed               reset HEAD and index
    --soft                reset only HEAD
    --hard                reset HEAD, index and working tree
    --merge               reset HEAD, index and working tree
    --keep                reset HEAD but keep local changes
    -p, --patch           select hunks interactively

But I am looking for any differences -

a) git reset --soft and git reset --keep
b) git reset --hard and git reset --merge

Signature · 9 lines
================
Regards,
Arup Rakshit
================
Debugging is twice as hard as writing the code in the first place. Therefore, 
if you write the code as cleverly as possible, you are, by definition, not 
smart enough to debug it.

--Brian Kernighan
#2 lore raw
In reply to Arup Rakshit
Quoted 6 lines · Arup Rakshit

Hi,
..

But I am looking for any differences -

a) git reset --soft and git reset --keep

git reset --keep is a safer version of git reset --hard. It will reset the working tree. but will abort when it has to overwrite uncomitted changes.

Quoted 1 line

b) git reset --hard and git reset --merge

git reset --merge does the same as hard, but keeps unstaged changes. When unstaged changes would need to be overwritted, it also aborts.

#3 lore raw
Quoted 6 lines
Quoted 3 lines · Arup Rakshit

From the command help I see -

[arup@to_do_app]$ git reset -h

You can also use "git help reset" to have the full man page. It has a lot more information.

Quoted 1 line
Quoted 1 line

But I am looking for any differences -

Do you have some use cases in mind?

Best,
Christian.