1.4 KiB
argument-hint, description
| argument-hint | description |
|---|---|
| <commit_hash> | Cherry-pick git commit into current branch by "patch" command |
Name
git:cherry-pick-by-patch
Synopsis
/git:cherry-pick-by-patch commit_hash
Description
The /git-cherry-pick-by-patch commit_hash command cherry-picks commit with hash
commit_hash into current branch. Rather then doing git cherry-pick commit_hash,
the command streams the output of git show commit_hash to
patch -p1 --no-backup-if-mismatch, and then commit changes with commit message
from commit_hash commit.
Implementation
Pre-requisites
The commit with hash commit_hash must exist. To verify that use:
git show commit_hash
and check if exit code is zero.
Fail, if there is no commit_hash in the current repository checkout.
Cherry-pick commit_hash into current branch
- Execute command
git show commit_hash | patch -p1 --no-backup-if-mismatch
and check if exit code is zero. Fail if exit code is not zero.
-
Find files removed from local checkout by the patch command and execute
git rmfor them. -
Find files added or modified by the patch command and execute
git addfor them. -
Commit changes by
git commitcommand and use commit title and description fromcommit_hashcommit.
Arguments
- $1 (required): Commit hash (e.g.,
902409c0) of commit to cherry-pick.