0

我试图能够做这样的事情:

> function gitb(){ git checkout -b $1; alias $1='git checkout $1'; }
> gitb sample
Switched to a new branch 'sample'
> git checkout master
Switched to branch 'master'
> sample
Switched to branch 'sample'

但是,函数 gitb 的行为不符合预期,因为:

> alias sample
alias sample='git checkout $1'

代替

> alias sample
alias sample='git checkout sample'

谁能告诉我如何实现我想要的目标?

4

1 回答 1

2

了解单引号和双引号之间的区别。

function gitb() { git checkout -b $1; alias $1="git checkout $1"; }
于 2012-04-20T01:42:51.970 回答