Is it possible to find the difference between two arbitrary text files using Git?

These files are not necessarily versioned.

FYI: I use git and git gui for windows xp.

+10
source share
4 answers

Yes, git diff works with two nonversioned paths, both files and directories (recursive difference). I do not think you can do this from the GUI; you will need to use the command line.

If you want a graphical interface, I suggest installing kdiff3 instead . It can also be used by git as a merge tool than if you set diff.tool = kdiff3 , diff.guitool = kdiff3 and difftool.kdiff3.path = path-to-kdiff3.exe

+6
source

You need to use the -no-index option if one or both files are not outside the git repository:

 git diff --no-index path/to/file.txt path/to/other/file.txt 

You can also use git diffftool with the same arguments to invoke the GUI tool.

+10
source

In git bash you can only use diff1 file of file2
Using tortoisegit - select both files, right click select tortoisegit and press diff.

+1
source

You can do this not only with git diff (using git diff --no-index -- file1 file2 ), but now (Git 2.22, Q2 2019) again with git difftool !
This has been impossible for the past two years.

" git difftool " can now work outside the repository.

See Commit 20de316 , Commit 1a85b49 , Commit 1dcda05 (March 14, 2019) by Johannes Schindelin ( dscho ) .
(Combined Junio ​​C Hamano - gitster - in commit b72e907 , April 25, 2019)

difftool : allow launching outside Git working trees with the --no --no-index option

As far as this developer can tell, converting a Perl script to an embedded one caused a regression in difftool that it no longer works outside of the Git working tree (with --no-index , of course).

It's a little awkward that after retiring the Perl version, it took more than two years to discover this regression, but at least now we know and can do something about it.

This fixes the git-for-windows/git 2123 problem .

0
source

Source: https://habr.com/ru/post/907214/


All Articles