Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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?

like image 448
Jonathan Day Avatar asked May 05 '11 00:05

Jonathan Day


People also ask

How can we locate a particular git commit?

Finding a Git commit by checksum, size, or exact file One of the “main” files in the repository that changes often is your best bet for this. You can ask the user for the size, or just a checksum of the file, and then see which repository commits have a matching entry.

What is a commit patch?

Patch is a text file, whose contents are similar to Git diff, but along with code, it also has metadata about commits; e.g., commit ID, date, commit message, etc. We can create a patch from commits and other people can apply them to their repository.

How can I see the log of a commit?

`git log` command is used to view the commit history and display the necessary information of the git repository. This command displays the latest git commits information in chronological order, and the last commit will be displayed first.


1 Answers

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

like image 151
manojlds Avatar answered Oct 13 '22 16:10

manojlds