As I mentioned in an earlier post entitled “Three commands for Subversion enlightenment“, Subversion’s diff command is quite helpful in determining what local changes have been made.
The output of the diff command is somewhat verbose in that it literally compares the local version to what’s in Subversion. If you’ve made a lot of changes, the output can be overwhelming.
For instance, running the diff command (for a sandbox where only one file has changed) yields output like so:
aglover$ svn diff
Index: test.properties
===================================================================
--- test.properties (revision 126)
+++ test.properties (working copy)
@@ -1,5 +1,5 @@
#HSQL Database Engine
-#Tue Jun 03 10:49:01 EDT 2008
+#Thu Jun 12 17:04:23 EDT 2008
hsqldb.script_format=0
runtime.gc_interval=0
sql.enforce_strict_size=false
In truth, most of the time, I just want to know what has changed not necessarily how. Accordingly, you can pipe the output of diff to a grep-like utility searching for the line containing the word “Index:” like so:
%>svn diff | egrep "Index:"
In my case, I’m using egrep to search for a line of text containing the keyword. If, for some reason, the files you are changing actually contain that word, you might want to precede the phrase with a ^ (which matches the starting position of a line).
Consequently, using this pipe filter yields the following output:
aglover$ svn diff | egrep "Index:"
Index: test.properties
Now I can more easily understand what files have changed and update a repository appropriately.

June 14th, 2008 at 8:09 am
Cool! Another similar svn command I like is “svn stat -u” which shows locally added/modified/deleted files as well as files which have changed on the server.
June 14th, 2008 at 8:41 am
Wouldn’t ’svn status’ give you the same info?
June 14th, 2008 at 11:18 am
Wouldn’t it be easier to just use:
svn status
This gives you output like so:
? juarezb
M bowman\index.html
? kenadjian\docs\2008\may2008_news.pdf
M kenadjian\index.html
M gilbert\index.html
? damon\docs\2008
M damon\index.html
June 14th, 2008 at 12:07 pm
I usually use
svn status | grep -v ‘^\?’
which also tells you whether files have been added, deleted, etc. (If you have your svn:ignores set right you don’t need to exclude the unrecognised files, but I’m usually too lazy for that.)
June 14th, 2008 at 12:30 pm
Yeah, you all are correct– svn status does give similar information; in fact, svn status is good at telling you what’s not in Subversion. I tend not to use ignore files, so the output of svn status has a lot of ?’s, which of course could be egrep’ed out!
Thanks!
June 14th, 2008 at 7:59 pm
Update! I think Andy’s suggestion of svn status | grep -v ‘^\?’ is more helpful than my svn diff command. Note, you must escape the ?.
Thanks, Andy!