Getting a list of all children of a given commit

后端 未结 4 950

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

4条回答
  •  旧时难觅i
    2020-12-03 06:36

    well, "--branches" or "--all" will include all branch tips, and then "--not A" will exclude A and all its ancestry. However, "--branches --not A" will include branches that don't include A, which I think is not what you need.

    There's no easy way to get everything you want, although you can work it out. This will list all the branches containing commit A:

    git for-each-ref refs/heads/* | while read rev type name; do
      git rev-list $rev | grep $(git rev-parse A) >/dev/null && echo $rev
    done
    

    then you need to list all the revisions reachable from any of those, but not A itself and any revisions back

    git rev-list $(git for-each-ref refs/heads/* | while read rev type name; do
          git rev-list $rev | grep $(git rev-parse A) >/dev/null && echo $rev
        done) --not A
    

    Note that I've only given this a very brief test :p But I think the fundamentals are sound.

提交回复
热议问题