80

Sometimes you're developing and you decide to commit, forgetting you created a few files on your project. Then a few days down the line your buddy gets your build out of Subversion and complains that some files appear to be missing. You realize, ah crap, I forgot to add those files!

How can I get a list of the files that are not under version control from Subversion so I'm sure I've added everything to the repository?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Doug T.
  • 64,223
  • 27
  • 138
  • 202

5 Answers5

111

Use the svn status command:

svn status | grep ^?

Files that are not versioned are indicated with a ? at the start of the line.

If you find that you always have some specific files that should not be added to the repository (for example, generated binaries), you should set up the svn:ignore property on the containing directory so these files won't keep showing up when using svn status.

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
  • 4
    Personally, I always "svn diff" before "svn ci", but since that's slow sometimes, I always "svn stat" before "svn diff", which is handy because then I don't forget to add stuff :) – ephemient Oct 23 '08 at 19:05
  • 11
    If you have many unversioned files that you'd like to add, do this: `svn st | grep ^? | awk '{print $2} | xargs svn add` This will first find unversioned files, awk will print only the second item in the line (i.e. the file path) and xargs will make this path an argument of svn add. – duality_ Sep 22 '12 at 23:30
  • 7
    A single quote is missing at the end of the awk command. The command should be: `svn st | grep ^? | awk '{print $2}' | xargs svn add` – jplandrain Jan 20 '14 at 13:20
51

If some files have had ignore added to their status, they won't show up in svn status. You'll need:

svn status --no-ignore
fidekild
  • 161
  • 3
  • 13
bleater
  • 5,098
  • 50
  • 48
  • 1
    Also helpful for binary files which in my setup seem to be ignored by svn status by default. I'm probably not aware of some setting that does this, but using --no-ignore has helped me in this scenario. – Andy Weinstein Nov 08 '17 at 08:54
  • This should be the accepted answer since the selected answer was not working in my case (for binary files in linux environment) – Asqan Apr 04 '18 at 09:45
15

If you're running on Windows, you could do something similar to Greg Hewgill's answer using PowerShell.

(svn stat) -match '^\?'

This could be extended pretty easily to find all unversioned and ignored files and delete them.

(svn stat "--no-ignore") -match '^[I?]' -replace '^.\s+','' | rm

Hope that's helpful to someone!

Community
  • 1
  • 1
Damian Powell
  • 8,655
  • 7
  • 48
  • 58
12

Or from the Windows command line:

svn stat | find "?"
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
crig
  • 859
  • 6
  • 19
1

You can use this command to list all paths for not-versioned files:

svn status | awk '/^?/ {print $2}'

The first part will do an svn status, and then it will redirect the output to AWK which will do simple filter "first character should be '?'" then it will print the second parameter "which is the file path".

svn status will always not print ignored files. You can add a file or path by adding that path using

svn propset svn:ignore "PATH OR PATERN"
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • This seems to get all results of `svn status`, not just non-versioned files. I believe the command should be `svn status | awk '/^\?/ {print $2}'` to escape the `?`, as the filter is a regex expression. – KymikoLoco Jul 03 '18 at 16:02