To cherry-pick a commit, follow these steps:
-
Identify the Commit: First, find the commit hash of the commit you want to cherry-pick. You can do this by running:
git log --oneline -
Switch to the Target Branch: Make sure you are on the branch where you want to apply the changes. For example, if you want to cherry-pick into the
masterbranch, switch to it:git checkout master -
Cherry-Pick the Commit: Use the
git cherry-pickcommand followed by the commit hash you identified earlier:git cherry-pick <commit_hash> -
Resolve Conflicts (if any): If there are conflicts during the cherry-pick, Git will pause the process and prompt you to resolve them. After resolving conflicts, you can continue the cherry-pick with:
git cherry-pick --continue -
Check the Commit: After a successful cherry-pick, you can check your commit log to see the new commit:
git log --oneline
This will apply the changes from the specified commit to your current branch as a new commit.
