Thursday, May 20, 2021

GIT - cherry-pick

you have two  branches. make a hot fix. apply that hot fix to other branches

cherry pick commit.

Here we create some changes in branch 'develop'.

Cherry-pick a commit from it and apply  to master branch


git status -> clean

git checkout -b develop

mate sample.txt -> 'cherry pick sample'

git commit -am "my cherry pick commit"

mate sample.txt -> "This won't be cherry picked"

git commit -am "non cherry pick commit"

git log --oneline -> will non cherry pick and cherry pick commit


copy the commit id of the 'cherry pick item'

git checkout master 

verify with

git status

git log --oneline --graph --all

mate sample.txt -> 'update away from develop branch'


git log --oneline --graph --all -> you can see last commit on master and previous two on develop branch'

-----------

*d4de234 update away from develop branch

| * c123452 non cherry pick commit

| * 1c23452 my cherry pick commit

|/

*6534123 express commit on README file


d4de234 -> on master

c123452 , 1c23452 -> on develop branch


let's do cherry pick '1c23452 my cherry pick commit'

git cherry-pick 1c23452


git status -> clean

Let's go and see the change

mate sample.txt -> you can see the change we did under 'my cherry pick commit' is in the 'sample.txt'. change is cherry-picked from develop branch to master branch

No comments:

Post a Comment