37

I have some files on my local Unix machine that need to be added to a Subversion repository (access via HTTPS). How do I do this?

Doing svn commit in the directory just says it's not a working directory.

1
  • 1
    svn add * --force Commented Mar 20, 2017 at 10:27

5 Answers 5

55
  • Checkout a working copy of the repository (or at least the subdirectory that you want to add the files to): svn checkout https://example.org/path/to/repo/bleh
  • Copy the files over there.
  • svn add file1 file2...
  • svn commit

I am not aware of a quicker option.

Note: if you are on the same machine as your Subversion repository, the URL can use the file: specifier with a path in place of https: in the svn checkout command. For example svn checkout file:///path/to/repo/bleh.

PS. as pointed out in the comments and other answers, you can use something like svn import . <URL> if you want to recursively import everything in the current directory. With this option, however, you can't skip over some of the files; it's all or nothing.

Sign up to request clarification or add additional context in comments.

6 Comments

The quicker option is to use svn import as @versionControlBuddy suggests
@ChrisMarotta that works if you are importing everything in a directory or a single file, but not for a subset of files in a directory. svn import accepts only a single path argument. To be honest, though, I did not know back then that svn import could be used with an already populated repository. In any case, thanks for pointing this out!
Remove .svn folder from your code to avoid conflict between two sub versions. Then add files.
@nordmanden you could try the --force option for svn import... no guarantees, though. I don't use SVN myself. My guess is that this simply isn't supported/allowed - so if it doesn't work, you're going to have to ask the SVN folks for the reason.
@nordmanden my impression is that Subversion merging is done within the repository, say from branch to trunk or from the repository to a working set. So if you do the checkout to create a working set, then update the working set, then do a commit, you are working with Subversion merge rather than against it. If the repository is empty then an import should be fine or you are creating a new folder in an existing repository where the content is going.
|
9

Probably svn import would be the best option around. Check out Getting Data into Your Repository (in Version Control with Subversion, For Subversion).

The svn import command is a quick way to copy an unversioned tree of files into a repository, creating intermediate directories as necessary. svn import doesn't require a working copy, and your files are immediately committed to the repository. You typically use this when you have an existing tree of files that you want to begin tracking in your Subversion repository. For example:

$ svn import /path/to/mytree \ http://svn.example.com/svn/repo/some/project \ -m "Initial import" Adding mytree/foo.c Adding mytree/bar.c Adding mytree/subdir Adding mytree/subdir/quux.h Committed revision 1. $ 

The previous example copied the contents of the local directory mytree into the directory some/project in the repository. Note that you didn't have to create that new directory first—svn import does that for you. Immediately after the commit, you can see your data in the repository:

$ svn list http://svn.example.com/svn/repo/some/project bar.c foo.c subdir/ $ 

Note that after the import is finished, the original local directory is not converted into a working copy. To begin working on that data in a versioned fashion, you still need to create a fresh working copy of that tree.

Note: if you are on the same machine as the Subversion repository you can use the file:// specifier with a path rather than the https:// with a URL specifier.

Comments

8

Normally svn add * works. But if you get message like svn: warning: W150002: due to mix off versioned and non-versioned files in working copy. Use this command:

svn add <path to directory> --force 

or

svn add * --force 

Comments

5

To add a new file in SVN

svn add file_name svn commit -m "text about changes..." 

To add a new file in a directory in SVN

svn add directory_name/file_name svn commit -m "text about changes" 

To add all new files in a directory with some targets (files) are already versioned (added):

svn add directory_name/* svn commit -m "text about changes" 

1 Comment

svn add directory_name/* svn commit -m "text about changes" this should work only make take time with the Transmitting file............................................ in linux.
1

Before you can add files in an unversioned directory, you have to add the directory itself to the versioning:

svn add directory_name 

will add the directory directory_name and all sub-directories: http://svnbook.red-bean.com/en/1.8/svn.ref.svn.c.add.html

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.