HomeToolsAbout a20k

Cherry-pick

How Cherry-pick works

When you want to apply a single commit from another branch into current branch

gitGraph
  commit
  commit
  branch develop
  checkout develop
  commit
  commit id: "123"
  commit
  checkout main
  commit
  cherry-pick id: "123"
  commit
graph LR
  A1["a"] --> A2["b"]
  A2 --> A3["c"]
  A3 --> A4["d"]

Bring in Specific Commit from Remote

You cannot pull specific commit from a remote; you can instead fetch the data and merge or cherry-pick

git fetch origin

View the code at specified commit_sha

git checkout commit_sha

Bring only the commit_sha to the destination_sha branch

git checkout destination_sha && git cherry-pick commit_sha

Bring all the changes leading up to commit_sha to the destination_sha branch

git checkout destination_sha && git merge commit_sha
© VincentVanKoh