Skip to content

Instantly share code, notes, and snippets.

@kohsuke
Created November 21, 2013 21:44
Show Gist options
  • Save kohsuke/7590246 to your computer and use it in GitHub Desktop.
Save kohsuke/7590246 to your computer and use it in GitHub Desktop.
Given a commit, find immediate children of that commit.
#!/bin/bash -e
# given a commit, find immediate children of that commit.
for arg in "$@"; do
for commit in $(git rev-parse $arg^0); do
for child in $(git log --format='%H %P' --all | grep -F " $commit" | cut -f1 -d' '); do
git describe $child
done
done
done
@kvudata
Copy link

kvudata commented Jan 17, 2018

Doesn't seem to work for me, I just get a "fatal: No names found, cannot describe anything."
I'm running git version 2.13.5 (Apple Git-94)

@sukima
Copy link

sukima commented Jan 11, 2019

@kvudata You need to provide one or more arguments to the command:

$ git children-of bada55commitish
$ git children-of bada55commitish | xargs git show

@xhd2015
Copy link

xhd2015 commented Apr 5, 2025

Just added to kool: https://github.com/xhd2015/kool/blob/master/tools/git_tag_next/show_children.go

(vibe coded, BTW)

go install github.com/xhd2015/kool
kool git show-children <commit>

Example output:

19d85a15f5f5fe9b23917ec0f95b0c249f9055fa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment