Git Cherry Pick
1 min read

Git Cherry Pick

Git Cherry Pick
Photo by Heather Gill / Unsplash

Git makes it easy to pull in commits from different branches, lets's say we want to pull in a specific commit from awesome-branch into our current working branch named current-branch. If the commit we want to pull in is behind a few other commits that we don't need, we can usegit cherry-pick to pull in the single commit we need.

tl;dr - how do I get a single commit from one branch into another branch

  1. Identify the commit hash from the commit you want to pull in from awesome-branch, lets's call this commit has 12345
  2. While the current-branch is checked out, run git cherry-pick 12345

That's it!

We can also pull in a series of commits using cherry-pick

Cherry pick multiple commits

git cherry-pick 12345 67890

Cherry pick a range of commits

git cherry-pick 1^..8