管道命令时git错误配置 [英] git bad config when piping commands
问题描述
这两个命令都可以从命令行运行。
git symbolic-ref HEAD | sed -es#^ refs / heads / ##
和
git branch | grep \ * | cut -d''-f2
在[alias]下添加到gitconfig中时
thisbranch =!git symbolic-ref HEAD | sed -es#^ refs / heads / ##
thisbranch2 =!!git branch | grep \ * | cut -d''-f2
我得到 fatal:bad config line 16在文件/ Users /< me> /。gitconfig
这是第二行。我最初的问题是让当前分支进入别名感谢这个答案。所以我主要好奇为什么两个都在命令行上工作,但只有1个可以在配置中工作。我猜测它是''
需要转义,但这只是一个猜测而已。
问题是您传递给 尝试双重转义通配符: Both of these commands work from the command line and When added to gitconfig under [alias] I get Your usage of single quotes looks fine. The problem is the wildcard argument you are passing to Try double-escaping the wildcard:
这篇关于管道命令时git错误配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! grep $ c的通配符参数
thisbranch2 =!!git branch | grep \\ * | cut -d''-f2
git symbolic-ref HEAD | sed -e "s#^refs/heads/##"
git branch | grep \* | cut -d ' ' -f2
thisbranch = !git symbolic-ref HEAD | sed -e "s#^refs/heads/##"
thisbranch2 = !git branch | grep \* | cut -d ' ' -f2
fatal: bad config line 16 in file /Users/<me>/.gitconfig
which is the second line. My initial problem was getting the current branch into an alias thanks to this answer. So I am mainly curious why both work on the command line, but only 1 can work in config. I am guessing it's the ' '
needs to be escaped, but that's just a guess.grep
is causing a syntax error.thisbranch2 = !git branch | grep \\* | cut -d ' ' -f2