tj.git-extras/man/git-delete-gone-branches.1
Utsav Sabharwal e92878b81b
feat: add git-delete-gone-branches command (#1239)
* feat: add git-delete-gone-branches command

Adds a new command to delete local branches whose remote-tracking
branch has been deleted (shown as [gone] in git branch -vv).

This is a common need after PRs are merged and remote branches are
cleaned up, leaving stale local branches behind.

Features:
- Deletes all local branches with a gone remote in one command
- --dry-run / -n flag to preview branches before deletion

Closes #1220

* Address PR review feedback on git-delete-gone-branches

- Use git for-each-ref instead of git branch -vv to avoid false
  positives from commit messages containing ': gone]'
- Add interactive confirmation prompt by default; skip with -f/--force
- Add -p/--prune flag to run git fetch --prune before checking
- Add generated man page .1 and .html files

* Use GitHub profile for author contact in man page

* Fix gone-branch detection with nobracket format
2026-06-09 10:36:27 +08:00

55 lines
1.3 KiB
Groff

.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "GIT\-DELETE\-GONE\-BRANCHES" "1" "March 2026" "" "Git Extras"
.
.SH "NAME"
\fBgit\-delete\-gone\-branches\fR \- Delete branches whose remote is gone
.
.SH "SYNOPSIS"
\fBgit\-delete\-gone\-branches\fR [\-n|\-\-dry\-run] [\-f|\-\-force] [\-p|\-\-prune]
.
.SH "DESCRIPTION"
Deletes all local branches whose remote\-tracking branch has been deleted\. This commonly happens after a pull request is merged and the remote branch is removed\. By default, lists the branches and prompts for confirmation before deleting\.
.
.SH "OPTIONS"
\-n, \-\-dry\-run
.
.P
Show the branches that would be deleted without actually deleting them\.
.
.P
\-f, \-\-force
.
.P
Skip the confirmation prompt and delete branches immediately\.
.
.P
\-p, \-\-prune
.
.P
Run \fBgit fetch \-\-prune\fR before checking for gone branches, to ensure remote\-tracking refs are up to date\.
.
.SH "EXAMPLES"
.
.nf
$ git delete\-gone\-branches
$ git delete\-gone\-branches \-\-dry\-run
$ git delete\-gone\-branches \-\-force
$ git delete\-gone\-branches \-\-prune
.
.fi
.
.SH "AUTHOR"
Written by Utsav Sabharwal <\fIhttps://github\.com/codersofthedark\fR>
.
.SH "REPORTING BUGS"
<\fIhttps://github\.com/tj/git\-extras/issues\fR>
.
.SH "SEE ALSO"
<\fIhttps://github\.com/tj/git\-extras\fR>