Git Cherry Pick
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
- Identify the commit hash from the commit you want to pull in from
awesome-branch
, lets's call this commit has12345
- While the
current-branch
is checked out, rungit 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