How to use bash commands for .gitconfig aliases

I am using a command git ls-tree -r $(git branch | awk '{ print $2 }') --name-only

to display files in my branch, but I tried to put this command in my file .gitconfig

as an alias and I got this error:

  $ git list
fatal: Not a valid object name $ (git

My .gitconfig file:

[alias]
list = ls-tree -r $ (git branch | awk '{print $ 2}') --name-only

Thanks Police Department Sorry for my english

+3


source to share


1 answer


As noted in the comments, you must prefix your alias with an exclamation point ( !

).

The following post works for me

[alias]
    list = !git ls-tree -r $(git branch | awk '{ print $2 }') --name-only

      

EDIT



Alternatively, following this answer, you can create a file git-list

anywhere in yours PATH

as shown below:

git -list

git ls-tree -r $(git branch | awk '{ print $2 }') --name-only

      

then change its execute permission with chmod +x git-list

and you can use the command git list

in any directory.

+3


source







All Articles