Skip to content

Git reset hard mode

git reset hard mode refers to a specific usage of the git reset command used to discard local changes and revert the repository state, often described as a "regret medicine" (後悔藥) for undoing actions.^[600-developer__tools__git__git-patch-cherry-pick.md]

Function

The command is used to forcibly reset the current branch's HEAD and the working directory to a specified state. By using the --hard flag, the user instructs Git to discard all changes in the working directory and staging area that are not present in the target commit.^[600-developer__tools__git__git-patch-cherry-pick.md]

Usage

A common use case involves resetting the branch to move backwards by one commit.^[600-developer__tools__git__git-patch-cherry-pick.md]

The command syntax for this action is:

[Git reset](<./git-reset.md>) HEAD^ --hard

Sources

  • 600-developer__tools__git__git-patch-cherry-pick.md
  • [[Git]]
  • [[Cherry-pick]]
  • [[Git Patch]]