-2

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
  • 21
  • 2

3 Answers3

9

One way . . .

git commit -F filename

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

Mike Sherrill 'Cat Recall'
  • 91,602
  • 17
  • 122
  • 185
-2

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

git commit -t some-template-file
eftshift0
  • 26,375
  • 3
  • 36
  • 60
-3

run the following command

cat message | xargs git commit -m
Joe
  • 399
  • 2
  • 7