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)