-4

How can I use a file as the commit message in Git?

I write my message in the file message, and I want to use it as the commit message while I executing git commit -a.

I tried:

$ git commit -a -m | cat message
$ cat message | git commit -a -m
$ git commit -a --message=`cat message`
$ cat message > git commit -a -m
$ cat message | git commit -a -m

But none of them works.

So is there anybody can solve my problem? Thanks!

OkayPJ
  • 1
  • 2

3 Answers3

7

One way . . .

git commit -F filename

See https://git-scm.com/docs/git-commit

Mike Sherrill 'Cat Recall'
  • 86,743
  • 16
  • 118
  • 172
-2

I think you need to use option -t some-file

git commit -t some-template-file
eftshift0
  • 20,217
  • 3
  • 33
  • 45
-3

run the following command

cat message | xargs git commit -m
Joe
  • 379
  • 3
  • 7