Monday, February 18th, 2008
Adding Multiple files to SVN repository
I was surprised that there was no built in way of adding multiple files to a SVN repository. I did a quick search and it seems that there is “one easy way” - execute the following piped command line from a Terminal window.
I could have sworn that I came across an easier way of doing this without resorting to doing the above.
Anyway, here’s what it does:
- it gets the status (svn st)
- looks for lines that start with a question mark (grep “^?”)
- then prints the second word for each line by using awk (awk { ‘print $2′ })
- THEN loop through the output the awk command does and add them one at a time.
I’ve come up with my own way of doing things through the use of backticks. I don’t know if this is more effective, but it skips the loop at the end used by the method above and instead issues one “svn add” command.
Basically, I get the list of unversioned files by executing the “awked” svn status on the fly through the use of backticks and feed it directly to the svn add command. So in essense it’s the same as typing: