简体   繁体   中英

How to get all commits committed to a branch which is already merged to master

I have a commit history like following:

A---B---C---D---E---F---J---K---L---M master
     \         /               /    
      G---H---I-----------N---O       bugfix

bugfix branch is based on commit B on master branch. It was merged many times to the master . Meanwhile there were other commits on master .

I want to get all the commits committed to bugfix branch G , H , I , N and O . Better as a patch file, much better including all commit messages so that after applying the patch I get 3 commits with the original messages. However, it is ok if I can get only the commit hashes without all those extra wishes.

The commits shouldn't include A and B although the bugfix branch is based on B .

Is that possible?

git format-patch I -3

You could use git am to apply these patches.

In some cases, the commit log message's subject might be formatted like [FEATURE][3348]add log-out in the menu , which includes [ and ] . You need to add --keep-non-patch in git am to keep the [] parts.

Updated: If you need all commits, git format-patch A..M or git format-patch A..HEAD . If A is needed, git format-patch --root M or git format-patch --root HEAD or just git format-patch --root .

git format-patch -$(git log --oneline | wc -l) seems also okay, which includes A.patch.

If you need only the commits of bugfix, git format-patch B..O

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM