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
.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With