简体   繁体   English

如何在gitconfig中使用别名正确使用bash变量

[英]How to use bash variable correctly in gitconfig with alias

This is my alias to create branch and set upstream on that branch later on: 这是我在以后创建分支并在该分支上设置上游的别名:

create = !sh -c \"branch=$(git branch | peco) 
          && git fetch origin ${branch}:${1} 
          && git checkout $1 
          && git branch -u origin/$(git current) fix/$1\"

But no matter I execute the follow command, it keeps showing syntax error, like this: new-branch-name: develop: command not found 但无论我执行follow命令,它都会显示语法错误,如下所示: new-branch-name: develop: command not found

What do I need to do to make the above alias works? 我需要做些什么才能使上述别名有效? Thanks a lot! 非常感谢!

There is not such a command name current in git.. 有没有这样的命令名称current Git中..

Here is your fix: 这是你的修复:

create = !sh -c \"branch=$(git rev-parse --abbrev-ref HEAD) && git fetch origin ${branch}:${1} && git checkout $1 && git branch -u origin/$(git rev-parse --abbrev-ref HEAD) fix/$1\"

On Multiple lines for easy reading: 在多行上方便阅读:

create = !sh -c \"branch=$(git rev-parse --abbrev-ref HEAD) 
         && git fetch origin ${branch}:${1} 
         && git checkout $1 
         && git branch -u origin/$(git rev-parse --abbrev-ref HEAD) fix/$1\"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM