SVN: set all files marked with “!” to “D”?

long story short, a mistake was made and now I have at least one hundred files throughout dozens of folders that need to be removed from my repository.

Right now they’re all marked as “!” in svn status and I’d like to remove them without manually typing in svn remove blahblah.

  • Smartgit error: “Push Error Not all refs have been pushed”
  • git project vs repository, what's the fundamental difference?
  • What is Repo and Why does Google use it?
  • Github “Failed to publish this branch” error on windows
  • Make a Hosted Repository a submodule of another Hosted Repository in Phabricator
  • Creating a git repository from a production folder
  • Is there a quick way to do this?

  • How to connect local folder to Git repository and start making changes on branches?
  • Is there a way to migrate SourceSafe with HISTORY into SVN?
  • Open Office and subversion compatibility
  • Setting up Gerrit with a Git mirror of a Subversion repository
  • How do I get information about a git repo using absolute paths
  • Same Django project different GIT repositories
  • One Solution collect form web for “SVN: set all files marked with “!” to “D”?”

    This is pretty easy to do with a little shell-scripting-foo.

    svn status | grep "^\!" | awk '{print $2}' | xargs svn del
    

    Here’s a breakdown, as requested:

    • The output of svn status is piped to grep
    • grep pipes every line that starts with a ! (The ^ in a regex means beginning of line, and the ‘\’ is necessary to escape the special meaning of !)
    • awk then takes the second “argument” (so to speak.. this is the path of the file) from grep and pipes only it to…
    • xargs which is simply a utility for building an executing shell commands from standard input, which generates and runs the command svn del your/file/here

    You can also use variations on this line to do all sorts of handy things with svn, like recursively adding files to the repo:

    svn status | grep "^\?" | awk '{print $2}' | xargs svn add
    

    Also, I just remembered, and wanted to point out that this will not work if you have spaces in your path or filenames. I always forget about that, because I never, ever do. If you have spaces in your paths/filenames, use the following variation on the first example:

    svn status | grep "^\!" | sed -e 's/? *//' | sed -e 's/ /\\ /g' | xargs svn del
    

    (There’s probably a more graceful way to do that, so feel free to chime in). In this one, the first sed takes the first whitespace character, and any (if any) spaces that follow it, and removes them (basically a trim). Then the second call to sed replaces any remaining spaces with \, which is an escaped space, as far as the shell is concerned. Come to think of it, you could probably just wrap it with quotes…

    Git Baby is a git and github fan, let's start git clone.