Take last N commits of the current branch and apply them to another branch

Viewed 4983

This is my scenario:

  • I'm in the master branch
  • From the master branch, the branch feature1 was created
  • Several commits were added to feature1 and other commits were added to master
  • Now, I want to take ONLY the last N commits from feature1 and apply them to master.

I want to go from this:

                       (branch) feature1: f1 > f2 > f3 > f4
                      /
(branch) master: A > B > C > D

To this:

                       (branch) feature1:  f1 > f2 > f3 > f4
                      /
(branch) master: A > B > C > D > f3 > f4
2 Answers
Related