Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
git-scripts
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
OmegaCEN
git-scripts
Commits
a2e0e487
Commit
a2e0e487
authored
7 years ago
by
Teake Nutma
Browse files
Options
Downloads
Patches
Plain Diff
Add delete-merged script
parent
044c9f23
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+4
-0
4 additions, 0 deletions
README.md
bin/git-delete-merged
+32
-0
32 additions, 0 deletions
bin/git-delete-merged
with
36 additions
and
0 deletions
README.md
+
4
−
0
View file @
a2e0e487
...
...
@@ -18,4 +18,8 @@ $ git log-mr [<revision range>]
# Lists local branches and their merge status, ordered by last commit date
$ git lastbranch [--merged <rev>]
# Deletes local branches that have been merged.
# Keeps master, develop, and the current branch by default.
$ git delete-merged [--merged <rev>] [--keep <regex of branches to keep>]
```
This diff is collapsed.
Click to expand it.
bin/git-delete-merged
0 → 100755
+
32
−
0
View file @
a2e0e487
#!/usr/bin/env bash
#
# Deletes local branches that have been merged. Keeps master, develop and the current branch by default.
#
MERGE_TARGET
=
'origin/develop'
KEEP
=
'master|develop'
while
:
;
do
case
$1
in
--merged
)
if
[
-n
"
$2
"
]
;
then
MERGE_TARGET
=
$2
shift
fi
;;
--keep
)
if
[
-n
"
$2
"
]
;
then
KEEP
=
$2
shift
fi
;;
*
)
break
esac
shift
done
current
=
$(
git rev-parse
--abbrev-ref
HEAD
)
git
for
-each-ref
refs/heads/
--format
=
'%(refname:short)'
--merged
"
${
MERGE_TARGET
}
"
|
grep
-v
-E
"(
${
current
}
|(
${
KEEP
}
))"
| xargs git branch
-d
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment