Getting a list of all children of a given commit

后端 未结 4 949

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条回答
  •  生来不讨喜
    2020-12-03 06:32

    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.

提交回复
热议问题