78

I have a working copy of a repository on my machine, and I know that it has been updated on the server. I would like to know how to get the difference between the new version and the version in my working copy by using svn command line arguments.

Is there a way for me to do this?

Mantas Vidutis
  • 16,376
  • 20
  • 76
  • 92
  • see also http://superuser.com/questions/150213/subversion-how-to-compare-differences-between-incoming-changes – craq Apr 28 '15 at 10:30

2 Answers2

119

The working copy is revision BASE. The latest copy from the repository is revision HEAD. This will compare your working copy against the HEAD revision:

svn diff -r HEAD <file>

Actually that'll spit the changes out in reverse, i.e. it tells you how to go from HEAD to BASE. So technically you want:

svn diff -r BASE:HEAD <file>

Can you spare the keyboard strokes? Only you and your deity know that answer.

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
  • 9
    The working copy file can be different from base (when you have local modifications to the file). You should realize that it diffs the file without the local modifications with the server. – Sander Rijken Sep 22 '10 at 21:19
  • Later answer addresses original question of diffing local modifications to HEAD – Chadwick Jun 28 '12 at 02:08
  • 3
    BASE is _not_ the working copy, see http://svnbook.red-bean.com/en/1.7/svn.tour.revs.specifiers.html – Aaron J Lang Feb 17 '14 at 18:18
18

The difference between working copy and HEAD; the changes which would need to be made to what is now in the repository (HEAD), to produce your working copy:

svn diff -r HEAD --old=<file>

Of possible interest, the difference between BASE and HEAD; changes that have been checked into the repository since you last updated working copy:

svn diff -r BASE:HEAD <file>

And of course the difference between BASE and working copy; the changes you have made since you last updated working copy:

svn diff <file>


There are three versions being discussed: BASE, working copy, and HEAD.

  • BASE: <file> as last checked out / updated. What working copy would revert to after using svn revert
  • working copy: local modifications to <file> which has been checked out / updated as recently as BASE
  • HEAD: latest modifications in repository. Equivalent to BASE iff no changes have been committed since <file> was checked out / updated as working copy.
Chadwick
  • 12,555
  • 7
  • 49
  • 66