Copy last commits from master to branch
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 ?
2 Solutions collect form web for “Copy last commits from master to branch”
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.
git merge is probably the best answer.
Another possibility is (again, from “pink”)
git cherry-pick 9a51fd2; ... for each of those changes. That will make individual new commits on pink. You can also name the branches as
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).