DEV Community

Reishi Mitani
Reishi Mitani

Posted on

 

Git Cherry-picking Smoothly

Suppose you want to pull one specific commit of Branch AAA into Branch BBB. To do this, first we will have to see the commit logs of AAA.

$ git checkout AAA
$ git log

commit 8edb903383e879561f9ae0e289e55example (HEAD -> features/xxxx-yyyy)
Author: exampleauthor
Date:   Tue Jul 21 11:42:11 2020 +0900

    some commit message

Enter fullscreen mode Exit fullscreen mode

Make sure to write down the commit id 8edb.... somewhere.

Now we move to branch BBB, and cherry-pick the commit

$ git checkout BBB
$ git cherry-pick 8edb903383e879561f9ae0e289e55example
Enter fullscreen mode Exit fullscreen mode

When you check the logs in branch BBB, you will see that BBB now has the commit that was previously only in AAA!

// in branch BBB
$ git log

commit 8edb903383e879561f9ae0e289e55example (HEAD -> features/xxxx-yyyy)
Author: exampleauthor
Date:   Tue Jul 21 11:42:11 2020 +0900

    some commit message
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Timeless DEV post...

Git Concepts I Wish I Knew Years Ago

The most used technology by developers is not Javascript.

It's not Python or HTML.

It hardly even gets mentioned in interviews or listed as a pre-requisite for jobs.

I'm talking about Git and version control of course.

One does not simply learn git