July 30, 2014 · git HowTo

Trick : Create .patch files from git log

Today i need to create a bunch of patch files from git commits. Just attempted the following script and it seemed to work

git log --pretty=oneline --abbrev-commit --since=11/Jun/2014 | gawk -F\  '{ print $1 }' | for i in `xargs`; do git show $i > $i.patch;done

You need to install git, gawk, xargs for this to work. I had specific requirement to get commits from 11th June to till date, so i sued the --since option, but you can skip it if you want.

  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pocket
Comments powered by Disqus