DEV Community

Dedar Alam
Dedar Alam

Posted on

Git Cherry Pick

git cherry-pick

  • Check out the branch you want to apply the changes to: git checkout
  • Use git log to find the commit hash of the change you want to apply
  • Run git cherry-pick to apply the change to your current branch

For example:

$ git checkout my-feature-branch
$ git log
commit ca82a6dff817ec66f44342007202690a93763949
Author: John Doe <johndoe@example.com>
Date:   Mon Mar 5 15:14:15 2021 -0800
Enter fullscreen mode Exit fullscreen mode

Add new feature X

$ git cherry-pick ca82a6dff817ec66f44342007202690a93763949
Enter fullscreen mode Exit fullscreen mode

This will apply the changes from the specified commit to the current branch. If there are any conflicts, Git will prompt you to resolve them before committing the cherry-picked changes.

Top comments (0)