git的分支VS $(GIT分支) [英] git branch vs $(git branch)
问题描述
当我执行的Git分支
在命令行中我得到一个回购所有分支的列表,但是当我执行 $(GIT分公司)
在一个子shell,它首先打印出在回购的顶层文件夹的文件打印出来的分支名称前的列表。为什么呢?
我基本上想遍历使用for循环分支,但文件的上市打破我的脚本。
因为我在$(GIT分支);做
回声$我
DONE
$ git的分支
*主
尝试回声*主
在你的shell,看看你得到了什么?
提示:你会得到从壳水珠扩展当前目录下的文件列表 *
请参阅 DontReadLinesWithFor 了解更多详情。
When I execute git branch
on the command line I get a list of all the branches on a repo, however when I execute $(git branch)
in a sub-shell, it first prints out a list of files in the top level folder in a repo before printing out the branch names. Why?
I'm basically trying to iterate over the branches using a for loop, but the listing of files breaks my script.
for i in $(git branch); do
echo $i
done
$ git branch
* master
Try echo * master
in your shell and see what you get?
Hint: You'll get the list of files in the current directory from the shell glob expansion of *
.
See DontReadLinesWithFor for more details.
这篇关于git的分支VS $(GIT分支)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!