Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9108797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:53:22+00:00 2026-06-17T02:53:22+00:00

I was wondering whether there is an efficient way to retrieve the children of

  • 0

I was wondering whether there is an efficient way to retrieve the children of a given commit.
Although a method was discussed in Referencing the child of a commit in Git, it is very inefficient.

I thought this would be a straightforward thing to be done in Git, but apparently, it is not.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T02:53:24+00:00Added an answer on June 17, 2026 at 2:53 am

    git rev-list can show children, but these children have to be reachable from the commits you provide. Assuming you want to show all children reachable from all branches in your repo, you can use something like

    git rev-list --all --not $COMMIT^@ --children | grep "^$COMMIT"
    

    This should output a line that looks like

    $COMMIT $child1 $child2 $child3 ...
    

    For convenience, you can add turn the command into a git alias by adding the following line to the [alias] section of your ~/.gitconfig:

    children = "!f() { git rev-list --all --not $1^@ --children | grep $(git rev-parse $1); }; f" # reachable children of a ref
    

    The syntax $COMMIT^@ might be confusing, so I’ll explain it. Hopefully $COMMIT is self-explanatory. This is then followed by ^@, which expands to all parents of the referenced commit. So $COMMIT^@ means "all parents of $COMMIT". Since this follows the --not flag, this instructs rev-list to stop processing after it hits any parent of $COMMIT. This is basically just an optimization, because any commit reachable from $COMMIT cannot possibly be a child.


    Note: a previous version of this answer said tail -1 instead of grep "^$COMMIT". This may work in a simple test repo (which is why I initially said it), but there’s no guarantee that git rev-list will emit $COMMIT last, if you have any branches that do not contain $COMMIT.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering whether there is a more pythonic (and efficient) way of doing
I'm wondering whether there's an efficient data structure to perform Retrieve all strings with
I am wondering whether there is an efficient way in MATLAB to generate all
Wondering whether there is an efficient way to add an item to Java's ArrayList
I'm wondering whether there is a way to poll a socket in c# when
I was wondering whether there is a way to check when the database was
I'm using TFS 2010 and am wondering whether there is an easy way, either
I was wondering whether there is a way in Boost.Spirit.Qi to dynamically combine an
Possible Duplicate: Shutdown Windows after simulation I was wondering whether there is a way
Just wondering whether there is a good way to upsert items in a CoreData

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.