1

Is there an equivalent in svn like git add -u? Basically, stage all the tracked files?

2240
  • 1,547
  • 2
  • 12
  • 30
David Liu
  • 16,374
  • 12
  • 37
  • 38

2 Answers2

3

There is no equivalent because SVN doesn't have a staging area. The usual SVN workflow is:

  1. Edit your files or add new files
  2. Run svn add <filename> to tell SVN you'd like to start versioning this file (see note), if any.
  3. Run svn delete <filename> to delete a file, if any.
  4. Run svn commit to send all of the changes to the repository on the server.

So changes to files that are already under version control require nothing more than svn commit to be sent to the remote repository; no staging is needed (or possible).

Note: Adding a file is almost like staging, but it's only for telling the next svn commit command to include a file that previously was not a part of the repository. The same goes for the delete command.

Patrick Quirk
  • 23,334
  • 2
  • 57
  • 88
2

The answer to your question is No, but in several different pieces:

  • There is no command in Subversion which will remove all deleted-in-working-copy files. Subversion generally expects you to use its own commands (svn copy, svn move, svn delete) whenever you modify the name/existence of a file; in the case of copies or moves, this is needed to record the file's history, but for deletions it is purely an annoyance.

    When I have the problem of telling Subversion about many deletions, I usually use the following command. However, this command is unsafe if any pathnames contain spaces, and will also need to be adjusted if future versions of Subversion add columns to status output (this has happened in the past). (The “right” way to do this would be to use svn status --xml, but I don't know of a commonly available tool to select data from XML and run commands or produce output suitable for xargs -0.)

    svn status | grep '?' | cut -c 9- | xargs rm
    
  • Because Subversion does not have staging as Git does, there is no such thing as staging changed files. The only way to have “unstaged” changes is to specify a list of files explicitly excluding those files when you commit.

  • This is not what you asked for, but it's closely related topic and useful but obscure: If you want to add all new files, you can use this command:

    svn add --force .
    

    The --force option when given to svn add actually means “if a versioned directory is found, recurse into it and add its children rather than skipping it” — it causes svn add . to operate the way git add . does for untracked files.

Kevin Reid
  • 37,492
  • 13
  • 80
  • 108