The [reset] Command

Reset current HEAD to the specified state

Usage

libra reset [OPTIONS] [COMMIT] [--] [PATHSPEC]...

Arguments

  • [COMMIT] - The commit to reset to. Can be a commit hash, branch name, or a reference like HEAD. Defaults to HEAD if not specified.
  • [PATHSPEC]... - One or more file paths to reset. When specified, the reset operation only affects the index for these files, not the HEAD.

Description

This command has two primary forms.

In the first form, it resets the current branch head (HEAD) to [COMMIT] and possibly updates the index (staging area) and the working tree, depending on the chosen mode.

  • --soft – Does not touch the index file or the working tree at all. It only resets the HEAD to point to the given commit.
  • --mixed – Resets the index but not the working tree. This is the default mode. All changes are kept in the working directory but are unstaged.
  • --hard – Resets the index and working tree. Any changes to tracked files in the working tree since the target [COMMIT] are discarded.

In the second form, if one or more [PATHSPEC] arguments are given, the command does not move the HEAD pointer. Instead, it resets the index entries for the specified paths to their state at the given [COMMIT]. This is commonly used to unstage changes.

Options

  • --soft Performs a soft reset. Only the HEAD pointer is moved. The index and working directory are not changed.
  • --mixed Performs a mixed reset. The HEAD pointer is moved and the index is reset to match. Changes in the working directory are kept but unstaged. This is the default mode.
  • --hard Performs a hard reset. The HEAD pointer, index, and working directory are all reset to match the specified commit. All local changes are lost.
  • -h, --help Print help

Example

  • libra reset --soft/mixed/hard commit
  • libra reset HEAD -- 1.txt 2.txt

Note:

All parameters should align with Git’s behavior as closely as possible, but there may be some differences. Refs https://git-scm.com/docs/git-branch for more information.