Is it possible to use a commit message from stdout, like:
echo "Test commit" | git commit -
Tried also to echo the message content in .git/COMMIT_EDITMSG
, but then running git commit
would ask to add changes in mentioned file.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityYou can use the -F <file>, --file=<file>
option.
echo "Test commit" | git commit -F -
Its usage is described in the man page for git commit
:
Take the commit message from the given file. Use - to read the message from the standard input.
You could always write a little function for it:
gcm(){
read message
git commit -m "$message" "$@"
}
Add that to your ~/.bashrc
or equivalent for your shell, and then run:
echo "Test commit" | gcm filename.to.commit
The command above will run
git commit -m "Test commit" filename.to.commit