32

I would like to add a file to a remote svn repository without checking out the project.

svn add requires the project to be checked out

svn import seems to only import directories

Any ideas?

Brig
  • 10,211
  • 12
  • 47
  • 71

4 Answers4

34

I think it got it. The secret is to include the file name on the url

svn import -m "Adding just a file" file_name http://path/to/svn/repo/file_name
Brig
  • 10,211
  • 12
  • 47
  • 71
  • Spot on, only thing I would add is, you could use a different file_name at the repository side, for example svn import -m "Adding just a file" file_name http://path/to/svn/repo/other_file_name – waynet Aug 18 '16 at 09:53
30

You should be able to use svn import:

$ svn help import
import: Commit an unversioned file or tree into the repository.

Import is able to add individual files and trees to a repository.

Sander Rijken
  • 21,376
  • 3
  • 61
  • 85
  • 4
    +1 `svn import` works with a single file. `svn import file.txt http://svn.example.com/repo/trunk/file.txt` – Alex Jasmin Oct 22 '10 at 20:19
  • 4
    If you need to specify user and password from shell, might help you: svn import --non-interactive --username theusername --password the password -m "Comment" /path/to/file http://path/to/svn/repo/filename – Saeven Mar 11 '13 at 17:16
  • To add multiple files, you need to put them in a separate folder, chdir to that folder and add the current durectlory, too bad it does not work like `cp`. – Vargas Jan 21 '18 at 17:40
4

This might not be what you are looking for but you can use -N flag to checkout a code non-recursively.

Example:

svn co -N http://svn.example.com/repo/trunk

This will not checkout all the sub-directories. Which is much faster if you are just trying to add a file.

Amir Raminfar
  • 33,777
  • 7
  • 93
  • 123
  • 4
    With a more recent SVN you can use `--depth=empty` which won't check out any files at all. – Rup Oct 27 '13 at 15:01
-7

SCMs are meant to version your code. Perhaps you want to use an FTP server.

Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141