57

How do I compare one branch with another? I want to compare a branch with the latest revision in trunk.

cchamberlain
  • 17,444
  • 7
  • 59
  • 72
tekumara
  • 8,357
  • 10
  • 57
  • 69

7 Answers7

75

You could start with:

svn diff http://REPOS/trunk http://REPOS/branches/B

(Where http://REPOS is your repository path including the parents of trunk and branches.)

This will print a large quantity of text, including all the textual changes but not the binary changes except to say where and when they occurred.

Edmund
  • 10,533
  • 3
  • 39
  • 57
20

If you are just looking for high level of what files are different and do not want to see all the contents, use:

svn diff ^/trunk ^/branches/dev --summarize

(This compares trunk and dev branch)

cchamberlain
  • 17,444
  • 7
  • 59
  • 72
  • 1
    For me in Linux I have to use escapes: `svn diff \^/[SUBPROJECT]/develop \^/[SUBPROJECT]/feature/myfeature/` – ephemerr Sep 29 '20 at 06:32
7

I usually check out the two branches (or the branch and the trunk) into directories. Then I use a graphical tool like Kompare or similar (depending on your preferences, operating system,...). This is really helpful for me when I need to perform complex merges.

CMorgan
  • 323
  • 3
  • 5
5

As lack of reputation won't let me add this as a comment against an existing answer, I'm having to add it as a separate one.

A useful option to svn diff for me was --ignore-properties. My two branches had ended up identical code wise, but with different merge histories.

Using --ignore-properties allowed me to prove to myself that this was the case, without wading through the large quantity of "svn:mergeinfo" property changes.

Michael Firth
  • 482
  • 5
  • 11
2

Thanks for the info guys, I would add something to improve the readability of the diff results.If you used: svn diff svn://url:9090/branches/PRD_0002 svn://url:9090/branches/TST_0003 >svn_diff_filename.txt

You can use: findstr "Index:" C:\path\svn_diff_filename.txt >svn_diff_file_list.txt

That will bring you a readable list of files that have any differences.

Wilduck
  • 13,822
  • 10
  • 58
  • 90
Kra.
  • 41
  • 1
0

Here's a post from Murray Cumming which describes the non-obvious process:

  • Discover the revision numbers: You need to know the revision numbers of the latest versions in each of the branches. It looks like svn log is the only way to do that.
  • cd into one of the branch directories, such as trunk.
  • Supply the revision numbers to the svn diff command: svn diff -r123:145
Stef
  • 6,729
  • 4
  • 34
  • 26
  • 3
    Won't this just tell you what's changed in `trunk` since the last commit to the branch? Apologies if I'm missing something - it's getting late here... – SimonJ Nov 24 '09 at 01:10
  • 1
    You don't need to look for the latest revision number in each branch: simply use `HEAD`. But this isn't what the OP was asking for -- he wanted to compare between his branch and trunk, not between two revisions in the same branch. – Ether Nov 24 '09 at 01:33
0

To diff between two revisions of a branch:

svn diff -r rLATEST:rOLD

Use svn log to get the different revisions. Use can limit the number of revisions in the log using svn log -l 5. only the last 5 revisions will be shown.

arush436
  • 1,748
  • 20
  • 20