Present situation in the picture. Green branch is a master. How to copy last 3 commits from master to pink branch, but without touching a master ?
git checkout <name of pink branch>
git merge master
will do exactly what you want (merge the 3 commits from master
into the pink branch, but leave master
itself where it is).
If you mean you wished you had waited to branch (and it's a personal project branch) you can (from branch "pink") use git rebase master
. That will pop off the pink commits, move pink
ahead to 29934b6 and then re-apply the patches.
Otherwise Amber's git merge
is probably the best answer.
Another possibility is (again, from "pink") git cherry-pick 9a51fd2; ...
git cherry-pick 9a51fd2; ...
for each of those changes. That will make individual new commits on pink. You can also name the branches as master
, master^
and master^^
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.