DEV Community

Reishi Mitani
Reishi Mitani

Posted on

3 2

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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay