Skip to content

Commit

Permalink
Add docs for new gem extracted from https://github.com/chrisk/git-extras
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisk committed Jul 26, 2012
1 parent 0e1288f commit 71ae873
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
24 changes: 24 additions & 0 deletions README.markdown
@@ -0,0 +1,24 @@
# git trimbranches

A handy little git porcelain to automate the removal of old topic branches
you've already merged to master.

## Installation

$ gem install git-trimbranches

## How it works

**Preflight:** First, it does a `git fetch` and `git remote prune origin` in the
current working directory to make sure your list of remote branches is
up-to-date.

**Finding branches that can be safely removed:** Then, it uses the `--merged`
option to `git branch` to find out which branches are already merged to
`origin/master`. It ignores branches with names including the words "master",
"staging", "production", or "stable".

**Deleting the branches:** Finally, it uses `git push origin :branchname` to
delete each of those branches from the remote. If a local copy of the branch
exists, it is also removed. The script prints the name of each deleted branch
with its SHA so you can recreate the branch if needed.
12 changes: 1 addition & 11 deletions git-trimbranches
@@ -1,17 +1,7 @@
#!/bin/bash
#
# git-trimbranches
# Removes branches on a remote that are subsets of its master branch, then also
# deletes local copies of those branches if they exist. Handy for removing old
# topic branches that you've already merged.
#
# It operates on the remote tracked by your local master branch (usually
# 'origin'), and skips branches with names containing the words master,
# staging, production, or stable.
#
# Usage:
# git trimbranches
#
# See README.markdown for information about this script.

function echo_in_bold_and_run {
printf "\033[1m%s\033[0m\n" "$1"
Expand Down

0 comments on commit 71ae873

Please sign in to comment.