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 ?

enter image description here

  • what should be in .gitignore file for a netbeans java project?
  • How to extract the source files from a git repository?
  • GitLab git user password
  • Protecting git deployment-specific files
  • git clone with NTLM proxy hangs after resolving deltas
  • Why does my Intellij Git plugin not commit files once I click commit?
  • failure to push to heroku on git deploying node server
  • Files showing as modified directly after git clone
  • Git add . Gives me Bus error (core dumped)
  • zlib error installing GIT on shared hosting
  • How can I 'git clone' from another machine?
  • How to git pull rebase using GitPython library?
  • 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.

    Otherwise Amber’s 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 master, master^ and 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).

    Git Baby is a git and github fan, let's start git clone.