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!

2
  • If there are no subdirectories, doesn't diff work directly on the top-level files in the two directories, without -r? Commented Jun 26, 2012 at 19:16
  • @vergenzt I did not try that. That would be handy. Commented Jun 26, 2012 at 20:35

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.