Removing .svn files from all directories [duplicate] - bash

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How do you remove Subversion control for a folder?
Command line to delete matching files and directories recursively
I recently converted my cvs repository to svn using cvs2svn and I recently noticed that every directory has a hidden folder called .svn. My current build script copies a lot of directories from my versioned resources directories and it ends up copying the .svn files. Is there anyway to make svn not include these files when I checkout or do I need to write a script to delete all these .svn files. There are many files that have these hidden .svn directories so this would be a pain unless I could write a recursive script to do this but I don't if I can do this for my windows installer. Is there an easy way to stop svn from putting this hidden directory everywhere in my project?

I'm not sure in your specific case that you want to remove all those .svn directories. But if you do, here is a bash one-liner to do just that:
find . -name .svn -print0 | xargs -0 rm -r

You can do a thing called an SVN Export to get the files without the .svn directories
http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.export.html

I posted this yesterday over here, but here is again because I kind of put it in the wrong thread anyway...
I've got something that should make your day. Original source is here.
This is a (perfectly safe) Shell Extension that will add "Delete SVN Folders" to your right click menu in Windows. Run it on any directory containing those pesky files.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN]
#="Delete SVN Folders"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN\command]
#="cmd.exe /c \"TITLE Removing SVN Folders in %1 && COLOR 9A && FOR /r \"%1\" %%f IN (.svn) DO RD /s /q \"%%f\" \""
To make this part of your build script copy that call to cmd.exe and execute it.

find . -name '.svn' -depth -exec rm -rf '{}' \; -ls

on Win32/Win64 systems, the following command should do the job:
del /q /s .svn

Those folders are required for how subversion works with a working copy (i.e. where you've done a checkout).
One option would be for you to do an export to another location. The export would not have the .svn folders, and you could run your script on that. Documentation: svn export, TortoiseSVN Export
Another option would be to modify your script to ignore hidden directories, or build a better build tool.

And a PowerShell version
ls -Force -Recurse -Filter .svn | rm -Force -Recurse

svn export is what you want. It will give you a clean copy of the code tree without the .svn directories (note that this copy is not under version control and svn commands won't work on it once it's exported).
I utilize this method to launch code on production servers. Our build script takes an export of the code branch, tars and gzips it, uploads it to the correct server, and unzips/untars it.

If wanna do this with ruby just paste my script at the root folder you want to remove recursively: http://fabianosoriani.wordpress.com/2009/03/19/ruby-script-to-remove-svn-folders/

You could take a look at SVK, which is a layer on top of Subversion. One of the advantages is that the repository metadata for your working copy, which is normally stored in the .svn dirs, is instead kept in a single central location, so you don't have the ugly hidden .svn dir problem. It's pretty nice.

find "/YourFolder" -name ".svn" -exec rm -fdR {} \;
Check this
link

I dont know if I would delete them, but maybe modify your build script to ignore copying them would be a good idea. I use Ant to build compile and build my war and it does so ignoring .svn dirs.

Related

How can I update modified date to current date in all files of a directory and its subdirectories? (Windows 10)

I need to update the modified date (and accessed date) of all files in a directory (Windows 10) and its subdirectories so that my company doesn't automatically delete them after a year of no modifications.
There might be thousands of files inside the directory so obviously, I can't do it manually.
It would be great if it could be done without using Python or other programming languages that need to be installed due to limited permissions in the system, directly with Windows CMD commands, but if it is necessary I might be able to get some temporary permissions.
As suggested in the comments, I've tried to use:
cd c:\yourFolder
copy c:\yourFolder,,+
But the solution doesn't update the files inside the subdirectories of my folder, so is there a way to do it for all the subdirectories in the tree?
Open the command prompt and navigate to your folder and execute the copy command with ,,+ params , example as follow.
cd c:\yourFolder
copy c:\yourFolder,,+
I have solved it by using the Windows PowerShell. After copying the complete directory, in PowerShell I did:
cd "C:\mydirectory"
dir -R | foreach { $_.LastWriteTime = [System.DateTime]::Now }
Which recursively "touched" all the files in the directory and subdirectories to make it look as if they had all been recently modified

git mv not working on windows to move files to a parent folder

I have tried every syntax I can think of but nothing has worked.
My repo all my files are in Files\MyFiles and I want to move them into the root of the repo.
The only command that has actually done anything without an error is
git mv ./Files/MyFiles/ ./
However all this did was move the MyFiles folder up one level. What I wanted to do was remove both of these folders so just the contents of MyFiles was in the root of the repo.
I have tried all kinds of stuff, adding wildcards, dots, changing the folder I'm in etc. but nothing has worked, I always get some variation of an error.
Is there a way to use this command correctly?
e.g.
C:\git\MyRepo [master ≡]> git mv ./Files/MyFiles/* ./
fatal: bad source, source=Files/MyFiles/*, destination=*
Go to child folder and run for /f %f in ('dir /b') do git mv %f ../ , it will move files from child folder parent folder

Subversion update all working copies under common parent directory

I am working on a number of projects simultaneously. Each project has a Subversion repository. The repositories are not all hosted on the same server. When I start my day, I find myself having to do an svn update for each of the individual projects.
My local working copies are all stored under one parent directory Projects.
My question: Is there a command that can be issued from the Projects directory that will search for working copies among the descendants in the file system and issue an svn update command for each of them?
I'm on Ubuntu with Subversion version 1.7.5.
cd to Projects and then:
svn up `ls -d ./*`
(note those are backticks, not single quotes.)
svn will happily skip non-svn dirs.
You could add an alias in your .bashrc
alias up-svn='svn up `ls -d ./*`'
You could just write
svn update *
That's it... Subversion will automatically recognize the working copies and do the update
One more suggestion similar to #thekbb answer
svn up `find ~/svn -maxdepth 3 -type d`
Explanation:
'~/svn' is my directory all checked out repositories are in
'-maxdepth 3' some repositories are nested (3 levels deep)
e.g. companyname/projectname/branch
'-type d' only directories
no, but you can easily write a script/batch file that calls "svn update" on each subdirectory.

is there anyway to clean up old svn directories and files from old source code tree

i have been sent a directory tree of source code that i want to import into my subversion repository. The issue is that at some point this code was in a different subversion repository. There are a huge number of directories and subdirectories and i basically want to clean up all of the subversion .svn folders before i attempt to import to a new repository and i dont want svn to get confused.
is there anyway to clean out a directory structure to remove all svn references?
svn export will produce a copy of the source tree without the .svn folders. Example:
svn export <old_project_root> <new_name_of_clean_directory>
I believe TortoiseSVN also has this capability from within a menu.
In the root of the project, with GNU find:
find . -name .svn -execdir rm -r {} +
EDIT: Corrected, with thanks to rkulla. -delete does not -delete non-empty directories.
Stefan, author of TortoiseSVN, has a complete explanation here. The gist of it is to use a built-in TortoiseSvn right-click helper to do the job like so:
(source: tortoisesvn.net)
For more possible solutions see the following question ‘Un-SVN’ a working copy.
One answer contains a Windows batch script that will cleanup all .svn folders.

Recursively search directories moving specified file type from one location to another preserving directory structure

Is there some way to specify a directory (let's say "C:\images") and move every .jpg file from there to another directory (say "D:\media") but preserve the directory structure (so if the file were "C:\images\paintball\july\07\headshot.jpg" after moving it would be "D:\media\paintball\july\07\headshot.jpg")?
I'm using cygwin (but would be happy to use DOS if that works too).
Yup.
Do a tar archive of *.jpg files while preserving directory structure (there's a switch) then extract it to the target directory. Should be a one-liner.
( cd /cygdrive/c/images
tar --create --file - . ) | ( cd /cygdrive/d/media
tar --extract --file - )
There's also a --directory option in some versions of tar with which you can avoid the complexity of piping between subshells, but I never use it myself, so I may be missing something:
tar --create --file - -C /cygdrive/c/images . | tar --extract --file - -C /cygdrive/d/media
If you need more power/flexibility, take the time to investigate rsync.
Since you're on windows, you could also take a look at xxcopy. It's great for this kind of stuff and much else.
You can also use xcopy command, like in this example (old is a directory):
xcopy cvs_src\*.jpg old /e/i/h/y/d/exclude:files_to_exclude
Thanks for the XCOPY solution, it solved my similar problem, so I thought I'd share the details for anyone else needing it.
I wanted a list (not a copy) of all the files in a directory (and sub-directories) that were not of a particular type, such as *.jpg. But the DIR command doesn't have an exclude function. So I:
Created a file named exclist.txt that contained a single line ".jpg"
Ran the command "xcopy c:\files c:\test /exclude:exclist.txt /l /d /e /h /i /y > found.txt"
Opened found.txt in Notepad to see the list of non-jpg files
Note the XCOPY /l parameter, which lists the files to be copied without copying them. Since XCOPY is executed in "list mode", the destination folder c:\test is not created and no files are copied. "> found.txt" saves the output from the XCOPY command to the file found.txt, rather than displaying the results on screen.

Resources