23

I guess I was careless.

I added a bunch of files to svn with svn add, then I saw a few files added that I didn't want so I deleted them with rm.

Now I can't commit anymore because the commit is missing files. I tried svn cleanup but it didn't help.

My working option now is to manually delete every .svn directory but that seems wrong.

2
  • 4
    You can svn revert the added files. Commented Aug 5, 2011 at 14:39
  • Believe me, you were not being careless. Svn should really be taking care of this for you, but it is not always that smart. Commented Sep 25, 2015 at 17:34

6 Answers 6

39

As I understand it you have this situation:

$ touch foo $ svn add foo A foo $ rm foo $ svn ci svn: Commit failed (details follow): svn: 'foo' is scheduled for addition, but is missing 

So to fix it do this: (thanks Linus!)

$ svn revert foo Reverted 'foo' 

or you can do this:

$ touch foo $ svn delete --force foo 

for each file, and you should be able to check in without problems.

Sign up to request clarification or add additional context in comments.

1 Comment

Didn't realize this actually deleted the file itself, not just the SVN tracking. Be aware that this removes the file from the local directory as well.
5

If you added a folder with sub-folders and files inside then you deleted the folder before you commit it. In this case you can do as the following.

$ svn revert <Deleted Folder Name> --depth infinity 

Comments

3

This is actually a slightly modified version of @Gonzalo Mateo, which solved my problem.

svn st | grep '!' | sed 's/!M \(.*\)$/"\1"/' | xargs svn revert --depth infinity 

Comments

2

If you have multiple directories with multiple files deleted, the following command could help:

svn st | grep '!M' | sed 's/!M \(.*\)$/"\1"/' | xargs svn revert 

I recommend first to list the files that are going to be reverted. We can do it by removing the last pipe: svn st | grep '!M' | sed 's/!M \(.*\)$/"\1"/'.

Step by step command explanation:

  • svn st - It lists added and unproperly deleted files with !M symbol
  • grep '!M' It finds the lines with !M
  • sed 's/!M \(.*\)$/"\1"/' This is used to get rid of the !M with the spaces. It will also quote the file names so you don't have to worry if files include spaces on them.
  • xargs svn revert This will revert all files listed.

2 Comments

Could you please elaborate more your answer adding a little more description about the solution you provide?
This question is nearly three years old. Also it would be helpfull to elaborate your answer a little bit more. Also note that the output of svn st may change without notice which would render your solution useless...
1

If you svn add X a file, but you haven't committed, then later you decide you want to delete that file (and not commit it); you should simply revert you svn add X command with svn revert X.

It will then "undo" the not yet committed add.

Comments

0

This solved my problem

svn st | grep '!' | sed 's/!M \(.*\)$/"\1"/' | xargs svn revert --depth infinity

One thing you should note is that the above code only works for the latest additions. So, do another svn ci if it gives an error then run the above code again. Then again svn ci until you have reverted every problem.

Bonus: Add an alias (this is for Oh-My-ZSH Zsh Shell)

# SVN revert everything like reset hard alias sra="svn st | grep '!' | sed 's/!M \(.*\)$/"\1"/' | xargs svn revert --depth infinity"

Now sra i.e. SVN Revert All will make your life easy.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.