添加env var以提交消息

时间:2017-09-21 11:08:48

标签: git bash commit

如何在Linux中为我的提交消息添加环境变量?

VERSION="1.0.0"

git commit -m "we add version " + $VERSION + " and that's it"

但这似乎不起作用。谁可以帮助我呢?

2 个答案:

答案 0 :(得分:6)

VERSION="1.0.0"
git commit -m "we add version $VERSION and that's it"

不需要使用+连接字符串,在双引号内保留空格。

答案 1 :(得分:2)

我犯了一个错误,就是使用-m围绕''消息。这将导致邮件只是“$YOUR_VAR”而不是内容。相反,请使用""

例如:

  git commit -m '$YOUR_VAR' # INCORRECT
  git commit -m "$YOUR_VAR" # CORRECT