Normally when I commit a change to a submodule in Git (and if that's the only change), I will provide the result of git diff <submodule-name> to the body of the commit message (with diff.submodule set to log in my git config). So the message would look something like:Updated Core SubmoduleSubmodule Core eaedd3f..0721763:  < Fixed ZA-123: Crash in rendering module  < Merge 'develop' into 'master'I've been trying to write a script that will automate this, to which I can tie to an alias in my git config. To generate the text above, ideally I'd like to run a command such as:$ git submodule-commit CoreThis would perform the following (roughly):Stage any change to specified submodule (Core in this case)Diff the change to the submodule and store that output text for the message generated laterRun git commit and provide the subject line (Updated $1 Submodule, or something of that sort, where $1 is Core in this example).Add the stored diff result from earlier to the commit message as wellI've not had any luck writing a simple script for this. I'm not very experienced with bash / shell scripts. Could anyone help provide an implementation that accomplishes this?
A bash script that can automate git commit message contents
scripting;git
The key bit of syntax you're missing here is:git commit -m $(printf Updated $submodule Submodule\n\n ; git diff $submodule)The use of the $() form of command substitution inside double quotes sends the output of git diff... to git commit as a commit message with newlines intact.I used printf here instead of echo to prepend the subject line since for anything even slightly complex  like dealing with embedded escapes  echo is basically nonportable, for historical reasons.The rest of the script is left as an exercise to the student. :)