SAGARFIVE

1. Introduction

2. Git Basics

3.  Git Terminology

4.  Git Branching

5.  Git - Github

6.  Git Add (Git staging)

7.  Git Commit

8.  Github Advanced

9.  Git Remote

7.14 Git cherrypick (copying commit chanes from one branch to another)

  • Cherry-picking copies the some commit information and changes from one branch into another branch.
  • It will create new commit and adds the changes/information
  • In case you made a mistake and committed a change into the wrong branch, but do not want to merge the whole branch. You can revert the commit and apply it on another branch.

Explaining with an example:

Copying specific commit from feature-1 branch to master branch using Git cherry-pick

Master branch :

Feature branch :

Steps :

(i). Checkout to a particular branch :  git checkout master

(ii). Command : git cherry-pick <commit-id>

(iii)To get commit id by this command : git log –oneline

Observations:

(i) Specific commit added to master from feature-1 branch as latest commit

(ii) We can see commit-hash of feature-1 is a5dee03 and the commit hash in the master is 64bd9e7
That means it creates a new commit and copies the files/changes/information