Dario Cancelliere
Dario Cancelliere

Reputation: 112

How to get changed lines only in diff in TortoiseGit or with Windows?

I have two (big) files and what I need is to extract changed/added lines only. Is a plain text file (CSV).

Simply return and save a third file with these lines..

UPDATE

I resolved with DiffMerge using the "Show Differences Only" function built in described here.

By the way, I still require a solution that "programmatically" do the same thing but I will create another Question maybe because I need it in a Linux environment.

UPDATE 2

Resolved also with TortoiseGit, see below.

Upvotes: 2

Views: 2740

Answers (3)

Yue Lin Ho
Yue Lin Ho

Reputation: 3111

  1. Select two files, and TortoiseGit -> Diff

enter image description here

  1. Create Patch file in TortoiseGitMerge

enter image description here

  1. the unified diff file

enter image description here


UPDATE

For viewing diff only, using "Collapse".

enter image description here


UPDATE 2

If you don't need the context, just set the "Context lines for patches" to zero.

enter image description here

Upvotes: 3

sendaran
sendaran

Reputation: 616

What you are looking for could be as simple as the default unified diff format given by git diff but with context lines stripped. You will still get the location information before every change.

git diff --unified=0 <commit1>:<path/to/file1> <commit2>:<path/to/file2> > <output file>

The files do not have to be versioned under Git, you can just omit the commit reference in that case (or when comparing separate files in same version). For different versions of the same file

git diff --unified=0 <commit1> <commit2> -- <file> > <output file>

Upvotes: 0

shakhawat
shakhawat

Reputation: 2725

diff --changed-group-format='%<' --unchanged-group-format='' file1 file2

Upvotes: 0

Related Questions