I have a Git commit, which has a summary, and then some description. So when I see the commit message via git log --format=%B -n 1 <commit>
, it looks like this:
Commit Summary Line
* Commit Description Line 1
* Commit Description Line 2
* Commit Description Line 3
When I try to store this in a Bash variable, however, thus:
message=$(git log --format=%B -n 1 <commit>)
and then I try to echo $message
, I get the folder names from my current directory mixed with each of the lines from the commit message. What's more, I am not even seeing all lines from the commit message, just some of them. So, $message
looks something like this:
Commit Summary Line folder1 folder2 folder3 Commit Description Line 1 folder1 folder2 folder3 Commit Description Line 3
Is there any explanation for this behavior? I just want $message
to have all lines from the full commit message. I don't even care if they are in new lines or all in one line, I just want all lines stored in a string variable. How do I achieve this?