1

I am using 'git log -p' to get the git patches. How to print the patch without the commit messages.

Author: abc
Date:   Tue Apr 1 23:46:39 2013 +0000
  I don't want commit message

diff --git 
..............
...........
--- /dev/null
+++

Expected:

Date:   Tue Apr 1 23:46:39 2013 +0000

diff --git 
..............
...........
--- /dev/null
+++
Twinkling Star
  • 135
  • 2
  • 14

2 Answers2

1

You can use something like git log -p --pretty='format:Date: %aD%n' to specify a pretty format that includes just the date. If you also want the object ID, you can write git log -p --pretty='format:commit %H%nDate: %aD%n'

If you're only interested in processing a single patch, you can also use the following

git format-patch --stdout HEAD^..HEAD | sed -n '/^Date:/p;/^diff --git/,$p'

You can do more advanced things with Perl or Ruby instead of sed if you want, which will allow you to process more patches.

bk2204
  • 64,793
  • 6
  • 84
  • 100
0
git log -p --format=

displays the patch without any part of the commit message. Similar to: https://stackoverflow.com/a/40837380/1959808

0 _
  • 10,524
  • 11
  • 77
  • 109