]> git.ipfire.org Git - thirdparty/git.git/commit
branch: add --forked filter for --list mode
authorHarald Nordgren <haraldnordgren@gmail.com>
Sat, 25 Jul 2026 11:32:10 +0000 (11:32 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sat, 25 Jul 2026 17:15:03 +0000 (10:15 -0700)
commit9be810b2a3591d89dffdcef39c58d2f59e0d48f0
treee3e811e4ddaec1da2699cf8ddb164eddaea23b50
parent94f057755b7941b321fd11fec1b2e3ca5313a4e0
branch: add --forked filter for --list mode

Add a --forked option to "git branch" list mode that lists only
branches whose configured upstream matches <branch>. The argument
can be a ref (e.g. "origin/main", "master"), a remote name like
"origin" for the branch its origin/HEAD points at, or a shell glob
(e.g. "origin/*"), and may be repeated to widen the filter.

It is an ordinary list filter, so it combines with the others:

    git branch --merged origin/main --forked 'origin/*'

lists branches forked from origin that are already merged into
origin/main, and --no-merged inverts the question.

This is the building block for --delete-merged, which deletes the
listed branches once they have landed on their upstream.

Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-branch.adoc
builtin/branch.c
ref-filter.c
ref-filter.h
t/t3200-branch.sh