git shame
[--[no]-color] [--remote REMOTE] [--[no-]show-commands] [--[no-]show-report] [--[no-]show-merged] [--[no-]show-unmerged] [--users [email protected], [email protected], ...]
Projects can accumulate a significant number of remote topic branches. Which are active? Which are safe to delete? Who "owns" them?
git shame
knows, and can help you clean these branches up (see EXAMPLES).
-
--color
Colorful output. This is automatically set when output is a TTY and the colored gem is installed.
-
--no-color
Turn off colors. This is the default when output is not to a TTY.
-
--remote REMOTE
Specify a remote branch. The default is origin.
-
--show-commands
Output shell commands to delete remote branches. This is off by default.
-
--no-show-commands
Do not output shell commands. This is the default.
-
--show-report
Output a report of remote branches, grouped by their "owners", ordered by staleness (time of most recent commit), showing their merged/unmerged status relative to the currently checked out branch. This is on by default.
-
--no-show-report
Don't show a report. You may want to use this in conjunction with
--show-commands
and pipe the output to sh(1) (be careful!) -
--show-merged
Show merged branches in report and command output. This is on by default.
-
--no-show-merged
Do not show merged branches in report and command output.
-
--show-unmerged
Show unmerged branches in report and command output. This is on by default.
-
--no-show-unmerged
Do not show unmerged branches in report and command output.
-
--users [email protected], [email protected], ...
By default,
git shame
's output includes all branches regardless of ownership. You may limit report and command output to branches "owned" by certain users, specified by a list of one or more email addresses separated by commas.
Before running any of these, make sure your local repo is up to date
relative to your remote. Run git pull
and git remote --prune
.
As the merged status is relative to the currently checked out branch,
be sure to git checkout
the branch you typically merge into (often this
is master or develop depending on the project's workflow).
-
git shame
Running with no options generates the standard report. The report groups branches by "owner", which
git shame
defines as the user who made the last commit to it. It's prettier if you have thecolored
gem installed. -
git shame --no-show-report --show-commands --show-merged --no-show-unmerged
This will output shell commands to delete all remote branches considered safe to delete (that is, they have been merged into the current branch). Resist the urge to pipe the output to sh(1)! Sanity check it first.
Daniel Rench
git(1), git-branch(1), git-remote(1), git-shame on github