Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion aria/contents/docs/libra/command/reset/index.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,46 @@
---
title: The [reset] Command
description:
description: 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 type="note" title="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.
</Note>
3 changes: 3 additions & 0 deletions libra/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ enum Commands {
Switch(command::switch::SwitchArgs),
#[command(about = "Merge changes")]
Merge(command::merge::MergeArgs),
#[command(about = "Reset current HEAD to specified state")]
Reset(command::reset::ResetArgs),
#[command(about = "Update remote refs along with associated objects")]
Push(command::push::PushArgs),
#[command(about = "Download objects and refs from another repository")]
Expand Down Expand Up @@ -118,6 +120,7 @@ pub async fn parse_async(args: Option<&[&str]>) -> Result<(), GitError> {
Commands::Commit(args) => command::commit::execute(args).await,
Commands::Switch(args) => command::switch::execute(args).await,
Commands::Merge(args) => command::merge::execute(args).await,
Commands::Reset(args) => command::reset::execute(args).await,
Commands::Push(args) => command::push::execute(args).await,
Commands::IndexPack(args) => command::index_pack::execute(args),
Commands::Fetch(args) => command::fetch::execute(args).await,
Expand Down
1 change: 1 addition & 0 deletions libra/src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub mod pull;
pub mod push;
pub mod remote;
pub mod remove;
pub mod reset;
pub mod restore;
pub mod status;
pub mod switch;
Expand Down
Loading
Loading