gritHEAD → docs/pick
Commands / Branches and tagsMarkdown

grit pick

Copy a single commit onto the current branch.

grit pick <commit>

Description

Takes the change <commit> made and applies it to the current branch as a new commit (a cherry-pick). The new commit keeps the original author and message. When commit.gpgsign is enabled, the new commit is signed like grit commit.

<commit> can be a full or short commit id, a branch name (to pick the commit at its tip) or an expression like feature~2.

grit pick works on one commit at a time and keeps it simple. It refuses, and changes nothing, when:

  • you have uncommitted changes, or the current branch has no commits, or HEAD is detached
  • <commit> is a merge commit
  • <commit> doesn't change anything, or its change is already on the current branch
  • the change conflicts with the current branch; the conflicting files are listed
  • an untracked file would be replaced by a path the pick would check out (same rule as grit switch)

Options

Option Description
<commit> The commit to copy onto the current branch.

JSON output

Pass --json for stable, scripting-friendly output:

Field Type Meaning
source string Full id of the commit that was picked.
oid string Full id of the new commit on the current branch.
subject string Subject line of the picked commit.

On failure because of conflicts, stdout is a single JSON object (exit code 1) with error, kind (conflict), and conflicts (sorted paths), same shape as grit merge.