I'm currently trying to cherry-pick a feature from the trunk of an OSS project into a fork. Both repositories use git and I have the trunk imported into the fork as a branch so it should make things nice and easy.
The approach I'm taking is to try to cherry-pick all relevant commits from one branch to another as it's not possible for me to just do a straight merge: there are too many things that have diverged.
In order to generate t开发者_运维知识库he list of commits I should start with to cherry-pick I've identified two git-log
commands to run:
git log --branch project-trunk **/*Foo*
This is intended to give me the log for any file with the word "Foo" in it on the project-trunk
branch. This is a pretty good starting point but I've found that there are other commits that are relevant: luckily they usually have an identifying work in the commit log. So to find these I'm using:
git log --branch project-trunk --grep Bar
This gives me any logs on the branch project-trunk
which contain the work "Bar".
The problem is that I really need a master list, ordered chronologically containing the union of both those commands. I've read the git rev-list
manual but I can't see any way of doing what I want.
Is it possible to union two seperate conditions like this? And if not, is there a simple way to union the output of two git-log
commands chronologically?
I got impatient and with a bit more playing around I came up with the following which seems to work:
(git rev-list --grep=Bar heads/project-trunk; git rev-list heads/project-trunk **/*Foo*) | git log --stdin --no-walk --reverse
If anyone can improve on it at all let me know! Hope this helps someone else in the future...
精彩评论