Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find all the direct descendants of a given commit [duplicate]

How can I find all the commits that have a given commit as parent?

For instance, if I have this Git commit graph,

   G   H   I   J
    \ /     \ /
     D   E   F
      \  |  / \
       \ | /   |
        \|/    |
         B     C
          \   /
           \ /
            A

I'd like to get a list of all the direct descendants of B : D, E and F.

like image 596
user2294139 Avatar asked Jan 15 '15 09:01

user2294139


1 Answers

You can use git rev-list --parents and filter the children of a parent with grep and awk

git rev-list --all --parents | grep "^.\{40\}.*<PARENT_SHA1>.*" | awk '{print $1}'

Replace <PARENT_SHA1> with the sha-1 hash of your B commit.

like image 60
René Link Avatar answered Sep 20 '22 09:09

René Link