-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add delete-squashed-branches command
#924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
spacewander
merged 3 commits into
tj:master
from
allejo:feature/delete-squashed-branches
May 27, 2021
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| targetBranch=$1 | ||
|
|
||
| if [[ -z $targetBranch ]]; then | ||
| targetBranch=$(git rev-parse --abbrev-ref HEAD) | ||
| else | ||
| git checkout -q $targetBranch | ||
allejo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fi | ||
|
|
||
| git for-each-ref refs/heads/ "--format=%(refname:short)" | while read branch; do | ||
| 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 | ||
| fi | ||
| done | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| .\" 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" | ||
| . | ||
| .SH "NAME" | ||
| \fBgit\-delete\-squashed\-branches\fR \- Delete branches that were squashed | ||
| . | ||
| .SH "SYNOPSIS" | ||
| \fBgit\-delete\-squashed\-branches\fR [<target\-branch>] | ||
| . | ||
| .SH "DESCRIPTION" | ||
| Deletes all git branches that have been "squash\-merged" into \fBtarget\-branch\fR\. | ||
| . | ||
| .SH "OPTIONS" | ||
| <target\-branch> | ||
| . | ||
| .P | ||
| The target branch were the "squashed\-merged" branches were committed to\. | ||
| . | ||
| .SH "EXAMPLES" | ||
| Delete all branches that were "squash\-merged" into the current checked out branch\. | ||
| . | ||
| .IP "" 4 | ||
| . | ||
| .nf | ||
|
|
||
| $ git delete\-squashed\-branches | ||
| . | ||
| .fi | ||
| . | ||
| .IP "" 0 | ||
| . | ||
| .P | ||
| Delete all branches that were "squash\-merged" into the \fBmain\fR branch\. This will checkout the target branch and leave you on said branch after the command has completed\. | ||
| . | ||
| .IP "" 4 | ||
| . | ||
| .nf | ||
|
|
||
| $ git delete\-squashed\-branches main | ||
| . | ||
| .fi | ||
| . | ||
| .IP "" 0 | ||
| . | ||
| .SH "AUTHOR" | ||
| Written by Teddy Katz <\fIteddy\.katz@gmail\.com\fR> and Vladimir Jimenez <\fIme@allejo\.io\fR> | ||
| . | ||
| .SH "REPORTING BUGS" | ||
| <\fIhttps://github\.com/tj/git\-extras/issues\fR> | ||
| . | ||
| .SH "SEE ALSO" | ||
| <\fIhttps://github\.com/tj/git\-extras\fR> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| git-delete-squashed-branches(1) -- Delete branches that were squashed | ||
| ===================================================================== | ||
|
|
||
| ## SYNOPSIS | ||
|
|
||
| `git-delete-squashed-branches` [<branch-name>] | ||
|
|
||
| ## DESCRIPTION | ||
|
|
||
| Deletes all git branches that have been "squash-merged" into `branch-name`. | ||
|
|
||
| ## OPTIONS | ||
|
|
||
| <branch-name> | ||
|
|
||
| The target branch were the "squashed-merged" branches were committed to. | ||
|
|
||
| ## EXAMPLES | ||
|
|
||
| Delete all branches that were "squash-merged" into the current checked out branch. | ||
|
|
||
| $ git delete-squashed-branches | ||
|
|
||
| Delete all branches that were "squash-merged" into the `main` branch. This will checkout the target branch and leave you on said branch after the command has completed. | ||
|
|
||
| $ git delete-squashed-branches main | ||
|
|
||
| ## AUTHOR | ||
|
|
||
| Written by Teddy Katz <<[email protected]>> and Vladimir Jimenez <<[email protected]>> | ||
|
|
||
| ## REPORTING BUGS | ||
|
|
||
| <<https://github.com/tj/git-extras/issues>> | ||
|
|
||
| ## SEE ALSO | ||
|
|
||
| <<https://github.com/tj/git-extras>> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should also update the doc
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this sound to you? 6867c79
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also need to update the output of
git delete-squashed-branches main?Would be better if we use
$ (branch) git ...to indicate the branch change.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! Is this a new convention or are there other commands that do this too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. But I think this way will be more clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this sound to you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alrighty! Amended to my last commit