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?
1 Answer 1
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
git checkout ffthengit cherry-pick abcde(regardless ofabcdebeing a commit hash or a branch name, which is unclear from your question). What do you call "a commit HEAD" here?git checkout ff; git cherry-pick HEAD@{1}.HEAD abcde? Just in case,HEADin git is always where you are standing.HEADis just the last revision of a repo.