When working with SVN repositories, developers often need to create directories in the repository without going through the full checkout-modify-commit cycle. While GUI tools like TortoiseSVN's repo-browser simplify this process, achieving the same via command line requires specific knowledge of SVN commands.
The svn mkdir
command with URL targets allows direct directory creation in the repository:
svn mkdir [URL] -m "commit message"
For example, to create a 'docs' directory in your repository:
svn mkdir http://svn.example.com/repos/myproject/docs -m "Creating docs directory"
When executing remote operations, you'll need proper credentials. Either:
- Use the
--username
and--password
parameters - Or configure your SVN client to cache credentials
svn mkdir http://svn.example.com/repos/myproject/docs --username johndoe --password secret -m "Authentication example"
Need to create multiple directories? Chain them together:
svn mkdir http://svn.example.com/repos/myproject/docs \ http://svn.example.com/repos/myproject/tests \ -m "Creating initial project structure"
- Parent directories must exist (unlike TortoiseSVN which can create intermediate paths)
- You need commit permissions on the target repository
- The operation is immediately committed (no staging area)
For more complex repository modifications without checkout, consider svnmucc
:
svnmucc mkdir newfolder \ mkdir newfolder/subfolder \ -m "Creating nested directory structure"
Many SVN clients like TortoiseSVN provide a repository browser feature that lets you create directories directly in the repository without performing a full checkout-commit cycle. This is particularly useful when you need to quickly add empty folder structures to version control.
The SVN command line offers similar functionality through the mkdir
command combined with remote repository URLs:
svn mkdir [URL] -m "Commit message"
Here are some common use cases with specific examples:
# Create single directory
svn mkdir https://svn.example.com/repo/new_folder -m "Adding empty directory structure"
# Create nested directories
svn mkdir https://svn.example.com/repo/parent/child \
-m "Creating nested directory structure"
# Multiple directories in one operation
svn mkdir https://svn.example.com/repo/folder1 \
https://svn.example.com/repo/folder2 \
-m "Batch creating directories"
When working with secured repositories, you'll need to include authentication:
svn mkdir https://svn.example.com/repo/secure_folder \
--username your_username \
--password your_password \
-m "Creating secured directory"
For more complex directory trees, you can combine this with other commands:
# Create temp working copy
svn checkout https://svn.example.com/repo temp_wc --depth=empty
# Add directories locally
mkdir -p temp_wc/project/{src,test,docs}
# Add and commit
svn add temp_wc/project/*
svn commit temp_wc -m "Creating project structure"
rm -rf temp_wc
- The parent directory must already exist in the repository
- You need commit permissions to the repository
- This method only works for empty directories
- Consider using
--parents
flag when working with complex paths