$ git branch --merged
Produces the following output
staging
fix-bug-260
new-featrue
hotfix
However if I try and script it using
for branch in $(git branch --merged)
do
git branch -d $branch
done
I get the following output
Deleted branch staging (was a041124).
Deleted branch fix-bug-260 (was b50b2a1).
Deleted branch new-feature (was ca8e106).
Deleted branch hotfix (was ge9a2j4).
error: branch 'Gemfile' not found.
error: branch 'Gemfile.lock' not found.
error: branch 'Procfile' not found.
error: branch 'Procfile.dev' not found.
error: branch 'Procfile.deve' not found.
error: branch 'README.md' not found.
error: branch 'Rakefile' not found.
error: branch 'app' not found.
error: branch 'bin' not found.
error: branch 'config' not found.
error: branch 'config.ru' not found.
error: branch 'coverage' not found.
error: branch 'data' not found.
error: branch 'db' not found.
error: branch 'doc' not found.
error: branch 'fixtures' not found.
error: branch 'lib' not found.
error: branch 'log' not found.
error: branch 'public' not found.
error: branch 'script' not found.
error: branch 'test' not found.
error: branch 'tmp' not found.
error: branch 'vendor' not found.
The script still works to clean up branches, but I'm not a fan of all the errors