获取给定提交的所有子代的列表 [英] Getting a list of all children of a given commit

查看:102
本文介绍了获取给定提交的所有子代的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在给定提交的所有子节点上运行 git filter-branch 。这似乎不是一件容易的事,因为似乎没有办法告诉 git rev-list 只返回特定提交的子代。使用..语法将不起作用,因为它也会包含该范围内任何合并的父提交。我在这里错过了什么?



edit



澄清:我有一个叫做 base ,它已被合并到衍生品多次。我想列出并最终运行 filter-branch ,只是从最近的提交中下载的提交。我还想在其他分支上列出类似的提交。



(简化)情况(衍生分支在左边):

$ $ $ $ $ g $ rev $ list $ - $ base $ $ $ $ $ $ $ $ $在最新的基本分支
| \
|中* 564d795afb63eab4ffe758dbcd726ca8b790f9f6拼写更正
* | 2f2ed5f1d429492e1491740e30be5a58ec20af21 snogg before flarg
| \\
| | /
| * 0c520ea33ef57b30846b122781d41fcef5e62f9b现在添加flarg
* | 5068c34c3862856f511b6b4d48f2adb766e1bde4现在增加了snogg
| /
* b51f227e931f830cbda042bc372087398ae7e50d初始提交

@ araqnid's建议似乎不起作用,除非我已经拙劣地阅读它:

  $ git rev-list --oneline derivative  - -not base 
f16fd151b374b2aeec8b9247489c518a6347d001最近从基地分支中合并
2f2ed5f1d429492e1491740e30be5a58ec20af21 snogg before flarg
5068c34c3862856f511b6b4d48f2adb766e1bde4现在添加了snogg

,因为除了 base 中的提交之外,这给出了衍生中的所有提交>。这种做法很有意义,因为它所做的只是去除否定提交的祖先。我想要它显示的仅仅是第一行。

显示祖先路径以提交 A 来自其他人:


git log - 祖先-path ^ a others

显示回购中所有无法访问的提交:


git fsck --unreachable --no-reflogs \

| awk'$ 2 ==commit{print $ 3}'


跟踪所有提交 A 回购中的任何地方:

  git log --ancestry-path  - graph --decorate --oneline ^ A \ 
--all $(git fsck --unreachable --no-reflogs | awk'$ 2 ==commit{print $ 3}')

显示其历史包含提交的所有引用:

  git log --ancestry-path --graph --simplify-by-decoration --oneline --all ^ A 
#如果A可能有直接引用,则添加:
git log --ancestry-path --graph --simplify-by-decoration --oneline A ^!

编辑:更正: A 本身就有其他孩子的父母。


I'd like to run git filter-branch on all children of a given commit. This doesn't seem to be an easy task, since there doesn't appear to be a way to tell git rev-list to only return children of a particular commit. Using the .. syntax won't work because it will also include the parent commits of any merge within that range. Am I missing something here?

edit

To clarify: I've got a branch called base which has been merged into derivative multiple times. I'd like to list, and eventually run filter-branch on, just the commits that descend from its most recent commit. I'd also like to list similar commits on other branches.

The (simplified) situation (derivative is the branch on the left):

$ git rev-list --graph --oneline base derivative
*   f16fd151b374b2aeec8b9247489c518a6347d001 merged in the latest from the base branch
|\
| * 564d795afb63eab4ffe758dbcd726ca8b790f9f6 spelling correction
* |   2f2ed5f1d429492e1491740e30be5a58ec20af21 snogg before flarg
|\ \
| |/
| * 0c520ea33ef57b30846b122781d41fcef5e62f9b now with added flarg
* | 5068c34c3862856f511b6b4d48f2adb766e1bde4 now with added snogg
|/
* b51f227e931f830cbda042bc372087398ae7e50d initial commit

@araqnid's suggestion doesn't seem to work, unless I've botched reading it:

$ git rev-list --oneline derivative --not base
f16fd151b374b2aeec8b9247489c518a6347d001 merged in the latest from the base branch
2f2ed5f1d429492e1491740e30be5a58ec20af21 snogg before flarg
5068c34c3862856f511b6b4d48f2adb766e1bde4 now with added snogg

as this gives all commits in derivative except for the commits in base. This kind of makes sense, since all it's doing is removing the ancestors of the negated commit. What I want it to show is just the first line.

解决方案

Show the ancestry paths to commit A from a set of others:

git log--ancestry-path^Aothers

Show all the unreachable commits in the repo:

git fsck --unreachable --no-reflogs \
| awk '$2 == "commit" {print $3}'

Trace all descendants of commit A anywhere in the repo:

git log --ancestry-path --graph --decorate --oneline ^A \
   --all $(git fsck --unreachable --no-reflogs | awk '$2=="commit" {print $3}')

Show all references whose history includes a commit:

git log --ancestry-path --graph --simplify-by-decoration --oneline --all ^A
# and in case A might have a direct ref, add:
git log --ancestry-path --graph --simplify-by-decoration --oneline A^!

edit: correction: don't show unwanted commits when A itself has parents with other children.

这篇关于获取给定提交的所有子代的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆