loading...

πŸ’What IS git cherry-pick? πŸ’

kojikanao profile image Koji (he/him) ・1 min read

What is cherry-pick

git-cherry-pick - Apply the changes introduced by some existing commits

https://git-scm.com/docs/git-cherry-pick

$ git cherry-pick [--edit] [-n] [-m parent-number] [-s] [-x] [--ff]
          [-S[<keyid>]] <commit>…​
$ git cherry-pick (--continue | --skip | --abort | --quit)

[Use case]
You are working on a branch from develop and your co-worker is also working on a branch from develop. He/She has fixed an issue(commit ID xxxyyyzzz000). You want to take in that bug fix from his/her branch, but you don't want to take in some commit he/she did.

Diff between merge and cherry-pick

Alt Text

$ git cherry-pick 61240658a3f26bd3b69cb961de4da9ef363fff35 # commit ID

How to check commit ID

  1. you can check it from log
$ git log

commit 61240658a3f26bd3b69cb961de4da9ef363fff35
Author: Koji <>
Date:   Thu Sep 24 16:41:16 2020 -0400

    Update programming.py

commit d85d4ddc01f2a28205c3e57abe8fe38f378f4857
Author: Koji <>
Date:   Thu Sep 24 14:54:23 2020 -0400

    Update programming.py

By the way, basically, you don't need the entire commit ID.
You just need around 6 digits from the end that GitHub shows on a repo.

  1. you can check it on GitHub/Gitlab etc

Go to your repo and check your commits on a branch
Alt Text

Discussion

pic
Editor guide