How to: Create a local SVN on Ubuntu
Often times I get into a situation where I mess up with my development (of personal projects). Though I use github for personal projects yet sometimes it is convenient to have a local SVN for all silly works (like .vimrc, .bashrc, etc…). After a lot of procrastination, I decided to set a local svn repo for all my silly “not-to-be-published” work.
Points to note
- First, understand that I am working on my personal box & so I got complete permission to violate 😉 the value of a sudoer account.
- Second, I am kinda cli person. Except for the joys of multi-window vim sessions I don’t want an overhead of apache et al. So I did not invest time in configuring my apache for my svn.
- Third, I am gonna access my SVN as a “file:///” & not as “http://” or “svn:///”
And, so here we go…
Install Subversion Package
Don’t expect an explanation here 😉
$> sudo apt-get install subversion subversion-tools
Create a directory to hold all your repositories. Since I own my box, to avoid confusion I created the repo directory as a peer to my user account. Another reason is this will ensure that my guest accounts (i.e., family et al) don’t get access to my SVN (by the virtue of they not being a sudoer).
$> sudo mkdir /home/svn
Create a new, empty repository at the path provided. Suppose, I want a repository for all my silly test works (like a super silly shell script to dump the current ip), I shall call it ‘test.’ Then:
$> sudo svnadmin create /home/svn/test $> ls -l /home/svn/ total 4 drwxr-xr-x 6 root root 4096 2014-09-18 18:32 test
This has created an empty repository under /home/svn/test.
Importing data implies that some data is available somewhere already. In my case, yes I do have my silly scripts to import and hence I change directory into where I have stored the scripts and import them as below:
$> cd ~/sillyscripts $> sudo svn import . file:///home/svn/test/trunk -m "Initial import"
Now the entire sub-tree under sillyscripts have been imported into test.
Final point to remember is that the original location from where the data was imported (i.e., ~/sillyscripts) is _NOT_ under svn. We need to freshly checkout the repo.
$> cd ~/svnprojects/ $> svn co file:///home/svn/test $> cd ~/svnprojects/test $> svn info Path: . URL: file:///home/svn/test Repository Root: file:///home/svn/test Repository UUID: 4158fc24-64e9-4705-b124-8f2b88018be7 Revision: 1 Node Kind: directory Schedule: normal Last Changed Author: root Last Changed Rev: 1 Last Changed Date: 2014-09-18 19:00:02 +0300 (Thu, 18 Sep 2014)
Voila! Now play with your data & have fun 🙂
- Creating Local SVN Repository (Home Repository)
- Getting Data into Your Repository
- How to create SVN repository on server?
- How To Set Up An SVN Repository In 7 Simple Steps