Tuesday, May 31, 2022

git- cherry-pick


git cherry-pick is a powerful command that enables arbitrary Git commits to be picked by reference and appended to the current working HEAD. Cherry-picking is the act of picking a commit from a branch and applying it to another. 


Create some commits in the dev branch and merge a particular commit in the main branch

  • git branch dev
  • git checkout dev
  • touch dev.java dev1.java
  • git add .
  • git commit -m "dev.java file is added" dev.java
  • git commit -m "dev1.java file is added" dev1.java
  • git log --oneline
  • git checkout -
  • git cherry-pick 6f39b22
  • git log --oneline
  • git cherry-pick 478bfdb -n # merge commit in stage area
  • git status
  • git commit -m "dev1.java"


Post a Comment