mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
Co-authored-by: Norbert Kiesel <nk@iname.com>
This commit is contained in:
parent
5f19424a50
commit
52897f73b9
|
|
@ -2,6 +2,12 @@
|
|||
|
||||
set -euo pipefail
|
||||
|
||||
proceed=false
|
||||
if [[ $# -gt 0 && ("$1" == "--proceed" || "$1" == "-p") ]]; then
|
||||
proceed=true
|
||||
shift
|
||||
fi
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
targetBranch=$(git rev-parse --abbrev-ref HEAD)
|
||||
else
|
||||
|
|
@ -13,6 +19,10 @@ git for-each-ref refs/heads/ "--format=%(refname:short)" | while read -r branch;
|
|||
mergeBase=$(git merge-base "$targetBranch" "$branch")
|
||||
|
||||
if [[ $(git cherry "$targetBranch" "$(git commit-tree "$(git rev-parse "$branch^{tree}")" -p "$mergeBase" -m _)") == "-"* ]]; then
|
||||
git branch -D "$branch"
|
||||
if [[ $proceed == true ]]; then
|
||||
git branch -D "$branch" || true
|
||||
else
|
||||
git branch -D "$branch"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
|
|
|||
|
|
@ -1,18 +1,24 @@
|
|||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "GIT\-DELETE\-SQUASHED\-BRANCHES" "1" "May 2021" "" "Git Extras"
|
||||
.TH "GIT\-DELETE\-SQUASHED\-BRANCHES" "1" "February 2024" "" "Git Extras"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBgit\-delete\-squashed\-branches\fR \- Delete branches that were squashed
|
||||
.
|
||||
.SH "SYNOPSIS"
|
||||
\fBgit\-delete\-squashed\-branches\fR [<branch\-name>]
|
||||
\fBgit\-delete\-squashed\-branches\fR [\-\-proceed, \-p] [<branch\-name>]
|
||||
.
|
||||
.SH "DESCRIPTION"
|
||||
Deletes all git branches that have been "squash\-merged" into \fBbranch\-name\fR\.
|
||||
.
|
||||
.SH "OPTIONS"
|
||||
\-\-proceed, \-p
|
||||
.
|
||||
.P
|
||||
Proceed with the next branch even if the current branch cannot be deleted (e\.g\. because it is checked out in a worktree)
|
||||
.
|
||||
.P
|
||||
<branch\-name>
|
||||
.
|
||||
.P
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@
|
|||
|
||||
<h2 id="SYNOPSIS">SYNOPSIS</h2>
|
||||
|
||||
<p><code>git-delete-squashed-branches</code> [<branch-name>]</p>
|
||||
<p><code>git-delete-squashed-branches</code> [--proceed, -p] [<branch-name>]</p>
|
||||
|
||||
<h2 id="DESCRIPTION">DESCRIPTION</h2>
|
||||
|
||||
|
|
@ -84,6 +84,10 @@
|
|||
|
||||
<h2 id="OPTIONS">OPTIONS</h2>
|
||||
|
||||
<p> --proceed, -p</p>
|
||||
|
||||
<p> Proceed with the next branch even if the current branch cannot be deleted (e.g. because it is checked out in a worktree)</p>
|
||||
|
||||
<p> <branch-name></p>
|
||||
|
||||
<p> The target branch were the "squashed-merged" branches were committed to. If no value is given, then the current checked out branch will be used.</p>
|
||||
|
|
@ -102,7 +106,7 @@
|
|||
|
||||
<h2 id="AUTHOR">AUTHOR</h2>
|
||||
|
||||
<p>Written by Teddy Katz <<a href="mailto:teddy.katz@gmail.com" data-bare-link="true">teddy.katz@gmail.com</a>> and Vladimir Jimenez <<a href="mailto:me@allejo.io" data-bare-link="true">me@allejo.io</a>></p>
|
||||
<p>Written by Teddy Katz <<a href="mailto:teddy.katz@gmail.com" data-bare-link="true">teddy.katz@gmail.com</a>> and Vladimir Jimenez <<a href="mailto:me@allejo.io" data-bare-link="true">me@allejo.io</a>></p>
|
||||
|
||||
<h2 id="REPORTING-BUGS">REPORTING BUGS</h2>
|
||||
|
||||
|
|
@ -115,7 +119,7 @@
|
|||
|
||||
<ol class='man-decor man-foot man foot'>
|
||||
<li class='tl'></li>
|
||||
<li class='tc'>May 2021</li>
|
||||
<li class='tc'>February 2024</li>
|
||||
<li class='tr'>git-delete-squashed-branches(1)</li>
|
||||
</ol>
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ git-delete-squashed-branches(1) -- Delete branches that were squashed
|
|||
|
||||
## SYNOPSIS
|
||||
|
||||
`git-delete-squashed-branches` [<branch-name>]
|
||||
`git-delete-squashed-branches` [--proceed, -p] [<branch-name>]
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
|
|
@ -11,6 +11,10 @@ Deletes all git branches that have been "squash-merged" into `branch-name`.
|
|||
|
||||
## OPTIONS
|
||||
|
||||
--proceed, -p
|
||||
|
||||
Proceed with the next branch even if the current branch cannot be deleted (e.g. because it is checked out in a worktree)
|
||||
|
||||
<branch-name>
|
||||
|
||||
The target branch were the "squashed-merged" branches were committed to. If no value is given, then the current checked out branch will be used.
|
||||
|
|
|
|||
Loading…
Reference in a new issue