git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: How can I download a git commit as a diff patch?

From
Jakub Narebski <jnareb@gmail.com>
Date
Sep 30, 2009, 20:40 UTC
Message-ID
<200909302240.17729.jnareb@gmail.com>
In-Reply-To
<20090930202527.GB22159@csclub.uwaterloo.ca>
On Wed, 30 Sep 2009, Lennart Sorensen wrote:
> On Wed, Sep 30, 2009 at 01:10:51PM -0700, Jakub Narebski wrote:
Show 19 quoted lines
> > Or better yet, if given installation of gitweb supports it, on the
> > 'patch' link just on the right of 'raw' view.  Such patch can be
> > applied better by git-am (but both should work for GNU patch or
> > git-apply).
> > 
> > Yes, by default for merges the 'commitdiff' view (and the 'raw'
> > version, i.e. 'commitdiff_plain' view) shows **combined** diff of
> > changes brought by merge (see git-diff manpage for details on this
> > format).
> > 
> > For merge commit you have to choose which of parents you want to have
> > diff from.  Go to 'commit' view, there in the header would be two or
> > more parents.  Click on the 'diff' link beside chosen parent, check if
> > it is the diff you want to get, and then click on 'patch' (or 'raw')
> > link.
> 
> Is there a git command to show me a diff I can use with patch if I want to
> select a given patch as long as I can tell it which tree I want to follow?
> I don't care to use gitweb if I can do it with the command line git.

You can specify parent explicitely: "git diff <rev>^1 <rev>" for diff to first parent, e.g. "git diff HEAD^ HEAD".

Show 5 quoted lines
> 
> git show obviously shows the git combined diff format, at least by default.
> 
> Or is the idea of trying to use the diff from the merge commit just
> silly in the first place?

Just so you know that this single diff is not enough to redo a merge. It is only partial information.

BTW. there is also "git diff-tree -m <rev>") to show diff to *all* parents at once:

    -m    By default, `git-diff-tree --stdin` does not show differences for
          merge commits. With this flag, it shows differences to that commit
          from all of its parents. See also `-c`.
-- 
Jakub Narebski
Poland
Previous: Lennart SorensenNext: Lennart Sorensen
Message 4 of 5 in “Re: How can I download a git commit as a diff patch?”
  1. Alejandro Riveira FernándezSep 30, 2009
  2. Jakub NarebskiSep 30, 2009
  3. Lennart SorensenSep 30, 2009
  4. Jakub NarebskiSep 30, 2009
  5. Lennart SorensenSep 30, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.