Skip to content
arxanas edited this page Aug 10, 2022 · 29 revisions

Description

New in v0.3.13.

git query is used to execute queries about the commit graph. You can use the results interactively or as part of your scripts. Since git query accepts revsets, you can issue more complicated queries than are possible with e.g. git log.

Usage

git query accepts a revset expression and prints out a list of commit hashes corresponding to the commits that matched that expression. The output is topologically-sorted, i.e. ancestor commits will appear before descendant commits in the list.

Querying branches

By default, git query prints a list of commits. If you want to get the branches attached to those commits, you can add the --show-branches option. For example, to get the list of all branches pointing to draft commits, you could run:

$ git query --show-branches 'draft() & branches()'
Clone this wiki locally