Invalid variable name in Bash from Git alias

I have the following Git alias in my global Git config.

pushnew = !f() { export tmp_branch=`git branch | grep '* ' | tr -d '* '` && git push --set-upstream origin $tmp_branch; unset $tmp_branch; }; f

      

When running, I get the following output:

 * [new branch]      bug/graphs -> bug/graphs
Branch bug/graphs set up to track remote branch bug/graphs from origin.
f() { export tmp_branch=`git branch | grep '* ' | tr -d '* '` && git push --set-upstream origin $tmp_branch; unset $tmp_branch; }; f: 1: unset: bug/graphs: bad variable name

      

I saw this question , but if this is a solution, then how to apply the fix in the context of a Git alias?

+3


source to share


1 answer


It should be:

unset tmp_branch

      



If you try to disable $tmp_branch

, the shell will replace the value $tmp_branch

trying to undo bug/graphs

.

+4


source







All Articles