I am writing code to programmatically run git commands and learn git at the same time. Am I reading manual pages incorrectly or is this what I want to make impossible?
The following describes how MYFILE has changed between two commits:
git diff COMMIT1..COMMIT2 - MYFILE
Good.
But let's say I just want to ask how COMMITX changed the file without specifying the previous commit. In my imagination, the syntax would be something like this:
git diff COMMITX -- MYFILE
or that:
git diff COMMITX^..COMMITX -- MYFILE
But the above commands do not work (for me).
The following works in the sense that it gives me a unified diff showing how COMMITX changed MYFILE, but it also includes other things that I have to cross out - for example, author, date, checkin msg. Itโs easy to clean up things, but it seems to me that I have nothing to do. Is there a team? Am I misunderstanding something?
git show COMMITX
EDIT1: I am showing here the actual output from my git bash window. I changed show to diff and didnโt get the output.
$ git show 789e9 - dir1 / file3.txt
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)
$ git diff 789e9 - dir1 / file3.txt
Administrator@BIOSTAR / c / temp / mygit (master)
source share