git的分支VS $(GIT分支) [英] git branch vs $(git branch)

查看:300
本文介绍了git的分支VS $(GIT分支)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我执行的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆