How do I get a "git log" patch for a specific commit

Jonathan Day picture Jonathan Day · May 5, 2011 · Viewed 13.9k times · Source

If I have a commit hash that has not yet been pushed to origin, how can I generate a patch for that commit only. I would like to use git log -p --no-names but can't see a switch to pass in a specific commit hash. Should I be using a different git command?

Answer

manojlds picture manojlds · May 5, 2011

For git log patch:

git log -p -1 <commit>

You should be using git format-patch for patches though:

git format-patch -1 <commit>

http://www.kernel.org/pub/software/scm/git/docs/git-format-patch.html