I currently work with an SVN checkout which tracks a separate GIT checkout (for reasons of managerial short-sightedness). When I update my git checkout, I find that the SVN checkout does not like the fact that files deleted by the git update have effectively been removed from the SVN checkout without the use of svn rm
. Consequently, it is impossible to commit the updated checkout into the SVN repository.
Fixing this manually is nigh on impossible if your checkout is complex with multiple nested subdirectories. The workaround is to use a neat trick using the svn status
output in tandem with grep, awk and xargs, as follows:
svn status | grep "^\!" | awk '{print $2}' | xargs svn rm
The above command locates - using grep - all lines in the output of svn status
beginning with a !
(which indicates a missing file). Once this is done, it uses awk
to print the second field, which in this case will be the filename of the missing entry. This name is piped to the svn rm
call using xargs
and the file is deleted by svn.
Once all missing files are deleted, we should be able to commit our new changes to the SVN repository.
This trick can also work when it comes to adding files newly added to the checkout. The only change is that instead of searching for lines beginning with a !
, we will be searching for a ?
. Once these are found, we will be using svn add
instead, as follows:
svn status | grep "^\?" | awk '{print $2}' | xargs svn add
- Log in to post comments