开发者

SVN - How to upload a single file?

开发者 https://www.devze.com 2023-01-06 01:49 出处:网络
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.

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 开发者_StackOverflow社区Desktop).

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


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.


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

  • svn co https://svn.internal.foo.com/svn/mycoolgame/branches/1.81
  • create your new file in the correct place in the folder structure checked out.
  • svn add your new file
  • svn ci -m "added file lalalalala" you new file

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.


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"


svn add filename
svn commit filename
0

精彩评论

暂无评论...
验证码 换一张
取 消