Git alias with shell variable expansions

后端 未结 2 1447
無奈伤痛
無奈伤痛 2020-12-21 01:58

I\'d like to use a shell variable expansion inside of a git alias to strip a prefix of a branch. Unfortunately when I use the \"standard\" alias, variable expansion is not d

2条回答
  •  难免孤独
    2020-12-21 02:38

    Try changing

    !git push -u origin ${$(git symbolic-ref HEAD)##refs/heads/}
    

    to

    !git push -u origin `git symbolic-ref HEAD | sed -e "s#^refs/heads/##"`
    

    This uses sh backticks to execute commands and sed to do the regular expression substitution.

提交回复
热议问题