Where to put SVN repository directory in Linux?
I like putting things under /srv
, as it seems to match the definition in the FHS.
How do I locate the SVN repository directory?
If your repository is served by Apache (because for svn://
picture differ), you have to
- Find your Apache configuration (httpd.conf)
- Locate the
Location
container inside the configuration file with SVN WebDAVDAV svn
- Identify method, used for defining repository location: it can be SVNPath or SVNParentPath directives
- In case of
SVNPath
the repository is placed directly on the path, defined as SVNPath parameter - In case of
SVNParentPath
it lists parent-path to all repositories
ADD-ON: "Light" version
d:\Repositories\Hello>dir /b
conf
dav
db
format
hooks
locks
README.txt
You can search for any repository-specific file or folder in Explorer ("hooks" is good candidate).
Where should I put my svn repository?
No, you're right that you shouldn't have the repository inside its own working copy. What you can do is use an Alias
directive (if you're using Apache) to map the directory /usr/local/svn/svn_repo
to the URL path /svn
.
Alias /svn/ /usr/local/svn/svn_repo/
This way when you direct your browser to http://linux-server/svn
, Apache will show you the contents of /usr/local/svn/svn_repo
, but that directory won't actually be inside /var/www
. You will also need to enable Apache to serve files from that directory, so put this in your Apache configuration file:
<Directory /usr/local/svn/svn_repo>
Order allow,deny
Allow from all
Options +Indexes
</Directory>
Note that you should also configure Apache with WebDAV so that you can access the repository over HTTP (otherwise Apache will show you the raw contents of the repository files, which won't be particularly easy on the eyes).
How to add an existing folder with files to SVN?
Let's say I have code in the directory ~/local_dir/myNewApp
, and I want to put it under 'https://svn.host/existing_path/myNewApp' (while being able to ignore some binaries, vendor libraries, etc.).
- Create an empty folder in the repository
svn mkdir https://svn.host/existing_path/myNewApp
- Go to the parent directory of the project,
cd ~/local_dir
- Check out the empty directory over your local folder. Don't be afraid - the files you have locally will not be deleted.
svn co https://svn.host/existing_path/myNewApp
. If your folder has a different name locally than in the repository, you must specify it as an additional argument. - You can see that
svn st
will now show all your files as?
, which means that they are not currently under revision control - Perform
svn add
on files you want to add to the repository, and add others tosvn:ignore
. You may find some useful options withsvn help add
, for example--parents
or--depth empty
, when you want selectively add only some files/folders. - Commit with
svn ci
How can I access the trunk directory of a new Subversion repository?
The repository directory created with svnadmin create
is essentially a database where Subversion stores information about files and their versions.
To access the files contained within the repository, you need to check out a working copy using the svn checkout
command. For example, the following command will check out the repository you created to a directory named /home/user/public_html/working
:
svn checkout file:///home/user/public_html/repo/myrepo /home/user/public_html/working
After checking out the repository, the /home/user/public_html/working
directory would contain trunk
, branches
and tags
subdirectories and you could then create a symlink:
ln -s /home/user/public_html/working/trunk /home/user/public_html/dev/
For further information, I'd recommend reading the Version Control with Subversion book (in particular the Fundamental Concepts and Basic Usage chapters).
.svn directory missing in new repository on Subversion 1.8 on centOS 6.x
After you create your repository you need to checkout first in different directory. This directory will be your working copy.
First create repository
svnadmin create --fs-type fsfs /var/www/svn/testrepo
then your working copy
cd $HOME
mkdir svnWorkingCopy
cd svnWorkingCopy
svn checkout file:///var/www/svn/testrepo .
mkdir trunk
mkdir branches
mkdir tags
svn add *
svn commit
Subversion / SVN: can I import into a local repository/directory?
OK, step=by-step
svnadmin create "D:/svn/test/"
OK, if you'll get ordinary FS-tree of repo in this dir (I saw, you got)
svn import . "D:/svn/test/"
FAIL. According to SVN Book, format if import is svn import [PATH] URL
(note the last word: URL). I.e.:
- if you have some data in . ("D:\TestPrj")
- if you want to add it into repository, placed at
D:/svn/test/
and not served by any SVN-capable server - you must to use file:/// protocol and full physical path in URL without quotes around URL
I can't recall and can't test, have you have backslashes or slashes in path, you have to try it (starting from backslashes, I suppose)
Remember that Subversion expects all repository paths in the form
file:///C:/SVNRepository/. Note the use of forward slashes throughout
svn import . file:///D:/svn/test
But I'll recommend perform (before import) two additional steps in order to make life more easier
- Don't import into root, follow recommended repo-tree and create
/trunk
/branches
/tags
hierarchy in root (import into trunk can be performed without preliminary created trunk, because "Parent directories are created in the repository as necessary...") - Run svnserve in easy and fast mode (listen on 127.0.0.1, root is root of your repo)
and import into svn://localhost/trunk (or maybe slightly different path according to your choice) and don't solve problems of physical path, quotes, slashes
Where svn store project code?
The subversion repository is basically a database; you won't see the literal names of files and directories if you inspect it directly. This follows from the purpose of subversion: to store the history of every file and folder, including its state at every past revision, and metadata such as log messages, and actions which change the directory structure, such as renames and deletes.
Laying out the repository the same way as the code being stored would be a very inefficient solution for this aim.
list directory entries in the svn repository?
If you are the subversion administrator, the following command will return the directories located in your repository.
svnlook tree $REPO_DIR --full-paths | egrep "/$"
The trick is the grep command that is looking for a trailing "/" character in the name
Same trick works for the svn command as well
svn list $REPO_URL -R | egrep "/$"
Extra notes
To repeatedly run this command you can put it into a shell for loop
for url in $URL1 $URL2 $URL2
do
svn list $url -R | egrep "/$"
done
Related Topics
Debian Start Qt Gui Application with No Desktop
Linux Service Can't Load Library Path in The /Etc/Ld.So.Conf.D
Detecting The Output Stream Type of a Shell Script
Bash Script That Creates a Directory Structure
Linux of Equivalent Cryptprotectmemory
Installing Oracle Instantclient on Linux Without Setting Environment Variables
How Are Interrupts Handled on Smp
(13)Permission Denied: Access to /Cgi-Bin/Test.Cgi Denied
Execute a Command in Another Terminal via /Dev/Pts
How to Get a Bash Script Working on Freebsd, Openbsd and Linux Without Modifying It
Read Serial Data Without High CPU Use
Linux: How to Lock The Pages of a Process in Memory
Identify Program That Connects to a Unix Domain Socket
Are System Calls on Windows Inherently Slower Than Linux