DenCowboy
DenCowboy

Reputation: 15076

Add env var to commit message

How do I have to add an environment variable to my commit message in Linux?

VERSION="1.0.0"

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

But that seems not to work. Anyone who can help me with it?

Upvotes: 3

Views: 4578

Answers (2)

Serguei Fedorov
Serguei Fedorov

Reputation: 7913

A mistake I've made, is to the surround the -m message with ''. This will cause the message to just be "$YOUR_VAR" and not the content. Instead, use ""

ex:

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

Upvotes: 9

P....
P....

Reputation: 18351

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

No need to concatenate the strings using + , inside double quotes spaces are preserved.

Upvotes: 15

Related Questions