title: What is "git" syntax for getting just the unified diff of how a single commit X changed a single file Y?
body: <p>I'm writing code to programmatically run git commands and learning git at the same time.  Am I mis-reading the man pages or is what I want to do not doable?   </p>
  
  <p>The following will tell me how MYFILE changed between the two commits:  </p>
  
  <blockquote>
    <p>git diff COMMIT1..COMMIT2 -- MYFILE</p>
  </blockquote>
  
  <p>Good.</p>
  
  <p>But, let's say I just want to ask how COMMITX changed the file, without specifying the prior commit.   In my imagination the syntax would be something like this:</p>
  
  <pre><code>git diff COMMITX -- MYFILE
  </code></pre>
  
  <p>or this:</p>
  
  <pre><code>git diff COMMITX^..COMMITX -- MYFILE
  </code></pre>
  
  <p>But the above commands don't work (for me).</p>
  
  <p>The following works in the sense that it gives me the unified diff showing how that COMMITX changed MYFILE, but it also includes other stuff I have to strip out - like author, date, the checkin msg.   Stripping out the extra stuff is easy, but it feels like it's something I shouldn't have to be doing.  Does the command exist?  Am I misunderstanding something simple?</p>
  
  <blockquote>
  <pre><code>git show COMMITX -- MYFILE
  </code></pre>
  </blockquote>
  
  <p>EDIT1: I'm showing here the actual output from my "git bash" window.  I changed the "show" to "diff", and got no output.</p>
  
  <pre>
  $ <b>git show 789e9 -- dir1/file3.txt</b>
  commit 789e948bce733dab9605bf8eb51584e3b9a2eba3
  Author: corey 
  Date:   Sun Oct 11 21:54:14 2009 -0500
  
      my msg
  
  diff --git a/dir1/file3.txt b/dir1/file3.txt
  index a351259..cf2bd35 100644
  --- a/dir1/file3.txt
  +++ b/dir1/file3.txt
  @@ -4,5 +4,7 @@ c
   ddd
   e
   f
  +a new line
  +another new line
   g
   h
  
  Administrator@BIOSTAR /c/temp/mygit (master)
  $ <b>git diff 789e9 -- dir1/file3.txt</b>
  
  Administrator@BIOSTAR /c/temp/mygit (master)
  </pre>