8

Here thoroughly means “list all differ files, find those files with same name and different content, list the difference of content”.

Before I got a lazy solution, git init one directory and copy another directory into it. Then using git diff to view the difference.

But I wonder there is another more smart way to do this? Thus I raised this question.

1
  • You do not need git init or copy directories, you can use (at least with the current version of Git) git diff --no-index. Commented Nov 1, 2020 at 12:44

2 Answers 2

11

diff -Naur dir1/ dir2/

Pretty useful for submitting software patches, incidentally: diff -Naur orig/ patched/ > my_changes.diff

2
  • Why I got strange stuffs like ����*�����;3[�� when using this command? The compared files containing utf-8 code. Commented May 20, 2015 at 3:52
  • Try diff -Naur -U8 dir1/ dir2/. (That may or may not fix the problem; it could have to do with the codepages in your kernel, how your terminal is set up, the underlying filesystem, etc.) Commented May 22, 2015 at 5:43
0

To complement on the response of @Bandrami, because I had the same problem @Zen did: before diffing the directories, make sure you cleaned all binaries and code unrelated files from dir2/, then compare the two directories. For instance:

$ cd dir2
$ make clean
$ cd ..
$ diff -Naur dir1/ dir2/

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.