Sometimes I include many files in different directories in my project. For now I am adding all files one by one to my project before commit. Is there any Linux terminal comm
Adds any file with a question mark next to it, while still excluding ignored files:
svn status | grep -v "^.[ \t]*\..*" | grep "^?" | awk '{print $2}' | xargs svn add
svn commit
http://codesnippets.joyent.com/posts/show/45
An approach using a Perl one-liner to add all files shown with a question mark by "svn st" would be:
svn st | perl -ne 'print "$1\n" if /^\?\s+(.*)/' | xargs svn add
This should also work with space characters in file names.
This shell script, recursively examines (svn status
) directories in your project, removing missing files and adding new files to the repository. It is some sort of "store into the repository the current snapshot of the project".
if [ $# != 1 ]
then
echo "usage: doSVNsnapshot.sh DIR"
exit 0
fi
ROOT=$1
for i in `find ${ROOT} -type d \! -path "*.svn*" `
do
echo
echo "--------------------------"
( cd $i ;
echo $i
echo "--------------------------"
svn status | awk '
/^[!]/ { system("svn rm " $2) }
/^[?]/ { system("svn add " $2) }
'
)
echo
done
By default, the svn add
command is recursive. Just point it at the top-level directory of your project and it should add any file not already there.
You may want to include the --force
option, though keep in mind that this will also add files which are otherwise excluded due to svn:ignore (if you don't use svn:ignore, then you won't have any issues).
None of you guys are fully correct I spend a whole night to fix it and it's running properly in my jenkins:
svn status | grep -v "^.[ \t]*\..*" | grep "^?[ \t]*..*" | awk '{print $2}' | sed 's/\\/\//g' | sed 's/\(.*\)\r/"\1"/g' | xargs svn add --parents
svn commit
I haven't used SVN. But the following should work.
svn add foo/bar.file bar/foo.file
This should add file bar.file
in the foo
directory and foo.file
existing in the bar
directory.
And svn add foo
should add all files in foo
to the server. The "recursive" flag is set by default.
And to add all files in a directory except for a few (like the files starting/ending with keywords tmp
, test
, etc.), I don't think there is a cleaner/simpler way to do it, and better write a shell script that does this.