3

Is there a way to specify the maximum recursion level for recursive diff diff -r (to compare two directories)?

What I'm trying to do is compare two projects on github (one was branched from another). I now suspect there may be a remote branch in one of them that links to the other, which will let me do a diff from git, however the question still applies to filesystems in general.

Edit-Update: This answer addresses how I might have git help me perform a comparison: https://stackoverflow.com/a/5162839/340947

What's been happening is I have cloned both repos and I am calling diff -r repoA repoB and it reports differences in the .git/ dirs, which is to be expected, yet I am uninterested in differences within these directories.

In this case it would be perfect to just show diffs between the first-level files in the directories, because this particular project does not have subdirs. If anyone has tips for how to compare two dirs while excluding particular folders (the .git/ dirs in my case) that'd be great too!

Community
  • 1
  • 1
Steven Lu
  • 41,389
  • 58
  • 210
  • 364

1 Answers1

5
  1. I'm not aware of any way of limiting the depth of recursion with diff -r.

  2. You can exclude files that match a pattern with -x PAT or --exclude=PAT. So

    diff -r -x .git repoA repoB
    

    would be useful if you did want recursion.

  3. In your case, just leave off the -r since you don't want it to recurse.

    diff repoA repoB
    

    already does what you want.

Darshan Rivka Whittle
  • 32,989
  • 7
  • 91
  • 109