header

Torsten Curdt’s weblog

Recursively adding files to CVS

The following commands can become handy if you are still stuck with cvs and cannot use the excellent eclipse cvs client.


  find . -type d -print | grep -v CVS | xargs cvs add
  find . -type f -print | grep -v CVS | xargs cvs add
  • Amit
    It is really a great solution. Thanks a lot for reducing my work.
  • Nikolaus
    Thanks, this is fantastic

    It did not work for me as specified under bash on OS X, I had to use the following, and note the -n1 parameter for xargs:

    find . -type d -print | grep -v CVS | xargs -n1 cvs add
    find . -type f -print | grep -v CVS | xargs -n1 cvs add

    the -n1 ensures that cvs add is called only for a single file each time. That's required because while cvs add can be called with a number of files as argument, if one of the arguments "aborts" the add, the others won't be added. I found that to happen with the first line which adds the directories. If a directory is already there, cvs add aborts instead of just skipping it like it does with files.

    So it would do a cvs add dir1 dir2 dir3, but because dir1 was already in the repository, it would not add dir 2 and 3. I am not sure it's required for files, but it can't hurt.
  • Thanks guys this is just what I needed. Don't have eclipse setup on my mac. :(
  • cowgod
    thank you, thank you, thank you. awesome.
  • Todd
    I love it.

    Thanks!
  • Be aware that the command uses "grep" and you might have grep aliased to some command lines. For example, as a programmer, I find this useful:

    alias grep='grep -n -i --color=auto'

    However, it fails the above commands. So you have to type "unalias grep" first.
  • fooball
    kinda the same solutions but w/o so much wasted pipes ;-)

    find . -type d -! -name CVS -! -name '.' -exec cvs add {} \;
    find . -type f -! -name CVS -! -name '.' -exec cvs add {} \;
  • fooball
    sorry copy the wrong line :)

    find . -type f -! -iregex ".*CVS.*" -exec cvs add {} \;
  • James
    -iregex is a gnu find only extension (as is -!, use \! instead), and really unnecessary since -iname \*CVS\* is the same as the .*CVS.* regex
  • Max
    Sweet, I use this all the time.
blog comments powered by Disqus