Git提交使用来自bash的stdout?

fug*_*ive 8 pipe git

是否可以使用来自 stdout 的提交消息,例如:

echo "Test commit" | git commit -
Run Code Online (Sandbox Code Playgroud)

还尝试在 中回显消息内容.git/COMMIT_EDITMSG,但随后运行git commit会要求在提到的文件中添加更改。

Ant*_*gan 21

您可以使用该-F <file>, --file=<file>选项。

echo "Test commit" | git commit -F -
Run Code Online (Sandbox Code Playgroud)

它的用法在手册页中描述git commit

从给定文件中获取提交消息。使用 - 从标准输入读取消息。