Content
    Commit Level

Git Reset

The git reset command is not very easy and can be dangerous in some cases. The git checkout command does similar things.

This overview is taken from the Pro Git book.

The meanings in the following tables are:

  • HEAD: Means that either HEAD itself is moved or the branch that HEAD points to (REF)
  • Index and Workdir: indicate what is changed by the command
  • Safe: If the command can overwrite uncommited changes it is not safe (work can be lost)

Commit Level

CommandHEADIndexWorkdirSafeNotes
reset --soft [commit]REF
reset [commit]REF
reset --hard [commit]REFjust replaces and overwrites files without waring
checkout <commit>HEADmerges files, aborts and warns in case of conflicts

File Level

CommandHEADIndexWorkdirSafeNotes
reset [commit] <file>
checkout [commit] <file>would be same as git reset --hard [branch] file but this is not allowed

HEAD is never changed with this commands.

Patch Option

Both commands, git reset and git checkout support the --patch option to allow to reset or checkout only part of changes.



  • Category

  • Programming

  • Tags

  • Git
    Version Control

  • Created

  • 28. September 2017


  • Modified

  • 17. March 2022