8

How do I upload a single file from my local computer to a SVN repository?

I can import a directory, but I can't import a single file into existing directory.

I use SVN in linux (command line).

Any help would be appreciated.

Edit: I forgot to mention, I need to upload this file into a specific directory that has nothing to do with directory structure in my local computer (say I upload from Desktop).

So I want to upload a file from Desktop to https://.../somefolder

Rok Povsic
  • 4,367
  • 5
  • 35
  • 47
  • http://stackoverflow.com/questions/768631/how-do-i-edit-and-commit-a-single-file-from-an-svn-repository – 0xAX Jul 09 '10 at 06:26

4 Answers4

27

This can be done as the OP requires.

svn import -m "Adding a new file" file_to_upload.ext http://example.org/path/to/repo/file_to_upload.ext

This allows uploading a file directly into the repository without checking out to a local working directory.

scottsome
  • 415
  • 1
  • 4
  • 5
13

Well, short answer is that it doesn't work like that :) In SVN you work with a checked-out revision of your repository. In order to "upload a single file" you have to "add" the file with "svn add foo.txt" and then run "svn commit -m "Added file foo" foo.txt". But you can only do this to an existing repository. Therefore you must first checkout the revision (rev of trunk or a given branch) of the repository to add the file to. So the entire steps would be something like

After this, you can delete your local copy again.

8-year edit: As mentioned svn import can also be used to accomplish this without having a local copy under version control. Do note though that this does so recursively and will add directories not present in the repository. This could be desired behavior or a source of potential errors depending on the situation.

inquam
  • 12,306
  • 14
  • 58
  • 101
1
svn add filename
svn commit filename
Thor
  • 42,211
  • 10
  • 116
  • 125
0xAX
  • 19,709
  • 24
  • 113
  • 202
1
svn add /path/to/your/file.txt
svn ci /path/to/your/file.txt -m "This is where the message goes"

Or if you havn't added anything else just commit with

svn ci -m "Your message"
Keyo
  • 13,157
  • 17
  • 76
  • 107