I have a feature branch ff
which is based on main
.
I want to bring changes made by a commit HEAD abcde
on top of ff
.
How can I do this?
Assuming you have checked out commit abcde
directly, which means your HEAD
is in a detached state, and you want to bring the changes made in that commit on top of your feature branch ff
, you can use git cherry-pick
.
git checkout ff
git cherry-pick abcde
git cherry-pick abcde
takes the changes introduced in commit abcde
and applies them as a new commit on top of your current branch ff
. This ensures that you bring only that specific commit without affecting other commits from the branch it originally belonged to.
If you encounter merge conflicts, Git will pause the cherry-pick and allow you to resolve them. After resolving, run:
git cherry-pick --continue
If you want to abort the cherry-pick due to conflicts, use:
git cherry-pick --abort