How can I get input for git commit message using variable?

How can I get input for git commit message using variable?
0

#1

Hi, campers!

I’m now encountered with bash script, while trying to make git automation file.
I tried to get input from user, and then use it for git commit message.
It is being executed without an error. But when I check the commit message in GitHub, the message is “$commitMessage”(variable name), not what I input, such as “error fixed”.

Can you help me to find out what I missed at this script?

Thanks in advance for your help!

Current bash file is as below.

#!/bin/bash
git add .
echo "Enter commit message: "
read commitMessage
git commit -m "$commitMessage"
git push

#2

That should be working, and when I create a test repo everything does work as expected.

Go into your repository and check the output of git log. Do you see $commitMessage, or do you see the message you typed in?