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
36 changes: 36 additions & 0 deletions aria/contents/docs/libra/command/cherry-pick/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
title: The [cherry-pick] Command
description: Apply the changes introduced by some existing commits
---

### Usage

libra cherry-pick [OPTIONS] <COMMIT>...

### Arguments

- <COMMIT>... - Commits to cherry-pick.

### Description

Given one or more existing commits, apply the change that each one introduces, recording a new commit for each. This is useful for selectively applying commits from one branch to another without merging the entire branch.

For each commit specified, cherry-pick will calculate the difference between that commit and its parent, and then apply that patch onto the current branch's HEAD. A new commit is created with the same log message as the original commit, but with a new commit ID.

If a conflict occurs, the operation will stop, and the user must resolve the conflicts before committing the changes manually.

### Options

- -n, --no-commit<br/>
Usually, the command automatically creates a sequence of commits. This flag applies the changes necessary to cherry-pick each named commit to the working tree and the index, but does not make the commit. This allows you to inspect and modify the result of the cherry-pick before committing.

### Example

\- libra cherry-pick commit1 -n
\- libra cherry-pick commit2 commit3

<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 @@ -55,6 +55,8 @@ enum Commands {
Merge(command::merge::MergeArgs),
#[command(about = "Reset current HEAD to specified state")]
Reset(command::reset::ResetArgs),
#[command(about = "Apply the changes introduced by some existing commits")]
CherryPick(command::cherry_pick::CherryPickArgs),
#[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 @@ -122,6 +124,7 @@ pub async fn parse_async(args: Option<&[&str]>) -> Result<(), GitError> {
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::CherryPick(args) => command::cherry_pick::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
Loading
Loading