Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to compare two directories in Git [duplicate]

Tags:

git

diff

meld

I have installed Meld as diff tool in Git. Is it possible to compare two folders using Git or any other way? I tried the following command but nothing happened.

git diff /c/sample/folder1/ /c/sample/folder2/
like image 861
gihan-maduranga Avatar asked Jul 21 '17 07:07

gihan-maduranga


2 Answers

If you want to compare two directories on your disk, no need for git :

# use any suitable diff viewer : meld, kdiff3 ...
meld /c/sample/folder1/ /c/sample/folder2/

If you want to have a directory view for the diff between two commits in git :

git difftool -d <commit1> <commit2>

# you can also restrict this directory view to a subdir of your repo :
git difftool -d <commit1> <commit2> -- lib/
like image 127
LeGEC Avatar answered Nov 15 '22 10:11

LeGEC


It actually is perfectly normal to compare different versions of folders in a git repository using git diff master..yourbranch path/to/folder (see this question).

If it's not about versions, but just comparing two folders, meld can do it:

Meld lets you compare two or three folders side-by-side. You can start a new folder comparison by selecting the File ▸ New... menu item, and clicking on the Directory Comparison tab.

(from here).

like image 35
kowsky Avatar answered Nov 15 '22 08:11

kowsky