0

Working alias for ref:

git config  --global alias.br "branch -vva"

The below alias not working

git config  --global alias.br "branch -vva  | awk '{print $1}'"

The Git alias is not working after adding awk in command. Does it have any fix for it?

Running alias as below in terminal:

git br
phd
  • 82,685
  • 13
  • 120
  • 165
JOEL
  • 29
  • 7
  • 2
    Without the conventional `!` shell escape there's no shell, alias processing is just argument list substitution. You want `'!git branch -vva | awk '{print $1}'` – jthill Jan 04 '23 at 13:21
  • 1
    See the end of; https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases – Adam Jan 04 '23 at 13:22
  • https://stackoverflow.com/search?q=%5Bgit%5D+alias+pipe – phd Jan 04 '23 at 13:28
  • I wouldn't call `!` "conventional" here. You don't have a choice in which prefix to use to indicate a shell command. – chepner Jan 04 '23 at 13:49
  • @jthill tried that too, but getting below error "expansion of alias 'br' failed; 'git' is not a git command" – JOEL Jan 04 '23 at 16:50
  • @chepner , thanks for the response, I just confirming it – JOEL Jan 04 '23 at 16:53
  • @chepner mmm, I can make sense of what you're saying but `!` is what everyone uses for shell escapes is the conventional use I was referring to. "Standard-practice" perhaps? – jthill Jan 04 '23 at 17:24
  • There's a typo in my comment there should be no leading singlequote. Sorry 'bout that. – jthill Jan 04 '23 at 17:25
  • @jthill "Standard practice" still implies you have a choice, but (most) everyone agrees to choose `!`. There is no choice here: `git` *mandates* that `!` be used to introduce a shell command to use as the alias. It's not a mere convention (like, for example, the use of `self` as the name of the first parameter in a Python method definition). – chepner Jan 04 '23 at 18:12
  • Yes, but Git had a choice. They chose to follow the convention. – jthill Jan 04 '23 at 19:45

0 Answers0