为什么合并git branch的脚本包含当前目录中的文件

时间:2014-07-29 19:17:23

标签: git bash

$ git branch --merged

生成以下输出

  staging
  fix-bug-260
  new-featrue
  hotfix

但是,如果我尝试使用

编写脚本
for branch in $(git branch --merged)
  do 
    git branch -d $branch
  done

我得到以下输出

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.

该脚本仍可用于清理分支,但我不是所有错误的粉丝

1 个答案:

答案 0 :(得分:1)

git branch --merged的输出包含*,因为您当前的分支可以保证合并到自身。这是一张shell外卡,它正在扩展,以包含工作目录中的所有文件。