By frank.bailey.jr ·August 5, 2026· 2 min read
Day ๐ฎ๐ด of the ๐ญ๐ฌ๐ฌ ๐๐ฎ๐๐ ๐ผ๐ณ ๐๐ฒ๐๐ข๐ฝ๐ ๐๐ต๐ฎ๐น๐น๐ฒ๐ป๐ด๐ฒ from KodeKloud
Day ๐ฎ๐ด of the ๐ญ๐ฌ๐ฌ ๐๐ฎ๐๐ ๐ผ๐ณ ๐๐ฒ๐๐ข๐ฝ๐ ๐๐ต๐ฎ๐น๐น๐ฒ๐ป๐ด๐ฒ from KodeKloud. Today's task was committing a change using Git Cherry Pick.
Here's the scenario. You are working on a branch of a repo. You have been developing and pushing commits, like a good diligent developer should. But a key component needs to pushed to the main branch, but you can't push up and merge your entire branch because it's not ready. What do you do, hotshot?
Answer: Use Git's Cherry Pick feature
With Git's Cherry Pick feature, you can choose a specific commit and push it directly to the main branch.
Before we start, here's the requirement for this task: โข One of the developers is working on the ๐ณ๐ฒ๐ฎ๐๐๐ฟ๐ฒ branch and their work is still in progress, however they want to merge one of the commits from the feature branch to the main branch, the message for the commit that needs to be merged into main is "๐จ๐ฝ๐ฑ๐ฎ๐๐ฒ ๐ถ๐ป๐ณ๐ผ.๐๐ ๐". Accomplish this task for them, also remember to push your changes eventually โข The repo is cloned at /๐๐๐ฟ/๐๐ฟ๐ฐ/๐ธ๐ผ๐ฑ๐ฒ๐ธ๐น๐ผ๐๐ฑ๐ฟ๐ฒ๐ฝ๐ผ๐
Here were the steps I took to complete this task.
CD in the correct directory
Find the Commit Hash of the commit you want to copy. I used ๐๐๐ ๐๐๐ ๐nd found the hash starting with 448b: [๐๐๐๐@๐๐๐๐๐๐๐ถ๐ท ๐๐๐๐๐๐๐๐๐]$ ๐๐๐๐ ๐๐๐ ๐๐๐ ๐๐๐๐๐๐ ๐บ๐บ๐พ๐๐๐๐๐ป๐๐๐๐๐ธ๐ฟ๐ธ๐ธ๐ธ๐ฝ๐บ๐ธ๐น๐ฟ๐๐น๐ผ๐พ๐๐ถ๐พ๐๐ท๐๐ผ๐ท๐พ๐ฟ๐ผ๐ท๐๐ฟ ๐ฐ๐๐๐๐๐: ๐ฐ๐๐๐๐ <๐๐๐๐๐@๐๐๐๐๐๐๐๐๐.๐๐๐> ๐ณ๐๐๐: ๐๐๐ ๐ฐ๐๐ ๐บ ๐ท๐บ:๐น๐ป:๐ป๐น ๐ธ๐ถ๐ธ๐ผ +๐ถ๐ถ๐ถ๐ถ
๐๐๐๐๐๐ ๐๐๐๐.๐๐ก๐
Switch to the Main Branch, ๐๐๐ ๐๐๐๐, and cherry pick the commit. You have to be in the main branch to ๐๐๐๐๐๐ข ๐๐๐๐ a commit from another branch. The command is ๐๐๐ ๐๐๐๐๐ข-๐๐๐๐ ๐ ๐ท <๐๐๐๐>: [๐๐๐๐@๐๐๐๐๐๐๐ถ๐ท ๐๐๐๐๐๐๐๐๐]$ ๐๐๐ ๐๐๐๐๐๐ข-๐๐๐๐ -๐ ๐ท ๐บ๐บ๐พ๐๐๐๐๐ป๐๐๐๐๐ธ๐ฟ๐ธ๐ธ๐ธ๐ฝ๐บ๐ธ๐น๐ฟ๐๐น๐ผ๐พ๐๐ถ๐พ๐๐ท๐๐ผ๐ท๐พ๐ฟ๐ผ๐ท๐๐ฟ [๐๐๐๐ ๐๐๐๐๐บ๐๐ธ] ๐๐๐๐๐๐ ๐๐๐๐.๐๐ก๐ ๐ณ๐๐๐: ๐๐๐ ๐ฐ๐๐ ๐บ ๐ท๐บ:๐น๐ป:๐ป๐น ๐ธ๐ถ๐ธ๐ผ +๐ถ๐ถ๐ถ๐ถ ๐ท ๐๐๐๐ ๐๐๐๐๐๐๐, ๐ท ๐๐๐๐๐๐๐๐๐(+), ๐ท ๐๐๐๐๐๐๐๐(-)
Afterwards, ๐๐๐ ๐๐๐๐ the cherry picked commit: [๐๐๐๐@๐๐๐๐๐๐๐ถ๐ท ๐๐๐๐๐๐๐๐๐]$ ๐๐๐๐ ๐๐๐ ๐๐๐๐ ๐ด๐๐๐๐๐๐๐๐๐๐ ๐๐๐๐๐๐๐: ๐ป, ๐๐๐๐. ๐ฒ๐๐๐๐๐๐๐๐๐๐ ๐๐๐๐๐๐๐: ๐ท๐ถ๐ถ% (๐ธ/๐ธ), ๐๐๐๐. ๐๐๐๐๐๐๐ ๐๐๐๐๐๐๐: ๐ท๐ถ๐ถ% (๐น/๐น), ๐น๐ท๐บ ๐๐ข๐๐๐ | ๐น๐ท๐บ.๐ถ๐ถ ๐บ๐๐ฑ/๐, ๐๐๐๐. ๐๐๐๐๐ ๐น (๐๐๐๐๐ ๐ถ), ๐๐๐๐๐๐ ๐ถ (๐๐๐๐๐ ๐ถ), ๐๐๐๐-๐๐๐๐๐๐ ๐ถ (๐๐๐๐ ๐ถ) ๐๐ /๐๐๐/๐๐๐๐๐๐๐๐๐.๐๐๐ ๐ผ๐บ๐ท๐บ๐ธ๐ธ๐ท..๐๐๐๐๐บ๐๐ธ ๐๐๐๐ -> ๐๐๐๐
I hope you found this informative! More to come!