admin管理员组文章数量:1292219
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?
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?
Share Improve this question asked Feb 13 at 10:39 pippip 294 bronze badges 7 | Show 2 more comments1 Answer
Reset to default 0Assuming 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
本文标签: gitBring Changes from a commit HEAD into a branchStack Overflow
版权声明:本文标题:git - Bring Changes from a commit HEAD into a branch - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741548016a2384709.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
git checkout ff
thengit cherry-pick abcde
(regardless ofabcde
being a commit hash or a branch name, which is unclear from your question). What do you call "a commit HEAD" here? – Romain Valeri Commented Feb 13 at 11:00git checkout ff; git cherry-pick HEAD@{1}
. – eftshift0 Commented Feb 13 at 11:34HEAD abcde
? Just in case,HEAD
in git is always where you are standing. – eftshift0 Commented Feb 13 at 11:35HEAD
is just the last revision of a repo. – eftshift0 Commented Feb 13 at 12:45