What is "git" syntax for getting just the unified diff of how a single commit X changed a single file Y? -
I'm writing the code to write the program and to run the git command and to learn the git at the same time. Am I reading man pages wrongly or do not I want to do this?
The following will tell me how the change between the two commits has changed:
git diff COMMIT1..COMMIT2 - MYFILE
Good .
But, suppose I just want to ask how the COMMITX has changed the file without specifying the permit. The syntax in my imagination would be something like this:
git diff COMMITX - MYFILE
or this:
Git diff COMMITX ^ .. COMMITX - MYFILE
But the above command does not work (for me).
The following work is in the sense that the unified difference shows me how COMMITX has changed the MYFILE, but it also includes other things, such as author, date, checkin msg. Stripping extra luggage is easy, but it seems that it should not be something I should do. What is the command? Do I have to understand something simple?
git show COMMITX - MYFILE
EDIT1: I'm displaying real output here from my "GIT Bash" window Converted "show" to "diff", and no output was found.
$ git show 789 9 / dir1 / file3.txt 789e 948bce733dab9605bf8eb51584e3b9a2eba3 Author: Cori Date: Sun Oct 11 21:54:14 200 9 -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 @@ Cdf EF + a new line + another new line BoAstar / C / Temp / Maggate (Master) $ $ b Administrator @ biostar / c / Try / gagit (master)
Try:
git shows --pretty = Format: & lt; Commitid & gt; - & lt; File & gt;
How it looks:
diff --git a / config.yb / config.y Index 7750514..f051b99 100644 --- A / Config.y +++ b / config.y @@ - 454,8 +454,8 @@ Diffinage Game: TYPE_DEFINE_GAME '{'} game_definitions '}' {- num_games = ncnf; Ncnf ++; + Num_games = NCNF; };
There is still an empty line in the beginning (due to Marcadoon limitations not shown here), but patch
will be ignored with pleasure (in fact, It also defines the header content as git show
output).
- Beautiful = oneline
is also useful:
3ed347de4c6e0e3230f651f82aabf964c6d16100 A bug Fix, where more than one defined game can not be seen or there is no difference / a / config.yb / config.y index 7750514..f051b99 100644 --- a / config.y +++ b / config .y @@-454,8 +454,8 @@ Diffinage Game: TYPE_DEFINE_GAME '{'} game_definitions '}' {- num_games = ncnf; Ncnf ++; + Num_games = NCNF; };
He said, if you are formatting a patch to deposit somewhere, then not left that stuff. In fact, use git format-patch
and enjoy it. Third party patching tools will happily ignore that extra metadata, and for projects using git, apply git
will use the provided message and the author's line, so that It will be easy to implement.
Comments
Post a Comment