git-log 带有“OR”子句 - 或 - 如何合并 git-log 输出?
我目前正在尝试从 OSS 项目的主干中挑选一个功能到分支中。两个存储库都使用 git,并且我将主干作为分支导入到 fork 中,因此它应该使事情变得美好而简单。
我采取的方法是尝试从一个分支到另一个分支挑选所有相关的提交,因为我不可能直接进行合并:有太多的东西已经分歧。
为了生成提交列表,我应该首先进行选择,我已经确定了两个要运行的 git-log 命令:
git log --branch project-trunk **/*Foo*
这旨在为我提供任何带有单词“的文件的日志” Foo”位于 project-trunk
分支上。这是一个非常好的起点,但我发现还有其他相关的提交:幸运的是,它们通常在提交日志中有一个识别工作。因此,为了找到这些,我正在使用:
git log --branch project-trunk --grep Bar
这为我提供了包含工作“Bar”的分支 project-trunk
上的所有日志。
问题是我确实需要一个主列表,按时间顺序排列,包含这两个命令的并集。我已经阅读了 git rev-list 手册,但我看不到任何做我想做的事情的方法。
是否可以像这样将两个单独的条件结合起来?如果没有,是否有一种简单的方法可以按时间顺序合并两个 git-log 命令的输出?
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 the 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我变得不耐烦了,经过更多的尝试,我想出了以下似乎有效的方法:
如果有人可以改进它,请告诉我!希望这对将来的其他人有帮助......
I got impatient and with a bit more playing around I came up with the following which seems to work:
If anyone can improve on it at all let me know! Hope this helps someone else in the future...