Search code examples
gitascii

git commit cannot convert \n to new line


On my Mac, I submit git information through the following command. I want git information to display newlines, so I added \n to the string. But it doesn't seem to work, and git won't wrap lines according to \n symbols:

commit_log1="111\n"
commit_log2="222"
git commit -m "${commit_log1}${commit_log2}" 

enter image description here

Does anyone know how to make git wrap lines according to the symbols in the string


Solution

  • This is working for me:

    git commit -m "$( echo -e $commit_log1$commit_log2 )"
    

    In bash, at least.