The Lumber Room

"Consign them to dust and damp by way of preserving them"

Svn locally (local Subversion for a single user)

with 5 comments

Because the existing top Google results suck, I keep having to waste time whenever I want to do this. [This = setting up a subversion repository in some directory on my filesystem, for use only by myself, so I don’t have to worry about remote access and what not.]

What should be the top result is Single-User Subversion on OnLamp.

Quick instructions:

  1. Decide a name (e.g. svnrepo) for the directory where the repository (the database etc., not the files) will be stored, go to the directory that will be its parent, and create the directory (and the repo) with: svnadmin create svnrepo.
  2. Decide a name (e.g. workspace) and location for your workspace (the directory where your files will actually be stored), and create it by checking out the (currently empty) repository into it with svn checkout file:///home/shreevatsa/path/to/svnrepo workspace.
  3. Go to the directory, create/copy files into it, add them with svn add filename, and commit with svn commit -m "Initial commit".

That’s it. Don’t bother with svn import, svn mkdir etc.

At any time, use
svn status to see what files have changed,
svn diff to see the diffs,
svn log to see history of your commit messages, and
svn update once in a while.
diff and log take arguments like -r 2:20 to mean revisions 2 to 20. HEAD stands for the most recent revision number, so you don’t have to know/remember it.

Just for completeness, my general SVN reference sheet:

==Initial setup (only once)==
   svn checkout svn+ssh://path/to/repo working-dir

==Work cycle (each time)==
   svn update    # to get the latest version from the repository

Now work with your files as you usually would. After you're done, do:
   svn diff      # to see what you have changed
   svn commit -m "some message, for the history"

Extra files you create in the directory are ignored. To add a new file, use:
   svn add [filename]

Update [2009-10-16]: For git (you can install it on Debian/Ubuntu with sudo apt-get install git-core, and on Mac with this), look here. It’s also very simple. The only counter-intuitive thing is that you apparently need to “add” modified files each time before committing, or use “git commit -a [-m message]“. In detail:

  1. Create the directory you want to manage, and cd into it. (It can also just be the directory that already contains your files.)
  2. Do git init. (This creates a .git folder.)
  3. Add the files you want, with git add FILE
  4. Commit, with git commit -m "message"

And the workflow each time is to edit files, then git commit -a -m "message" to commit. git status and git diff are self-explanatory. You can do git config --global --add "commit -a -m" to be able to just type git cam "message", and git config --global --add diff.color true for colours. (The --global refers to ~/.gitconfig.)


Written by S

Thu, 2008-09-25 at 19:03:42

Posted in Uncategorized

5 Responses

Subscribe to comments with RSS.

  1. I would use svk for local repos. And also for local copies of other SVN repos. While svk isn’t a supercool distributed versioning system, it does work well.


    Thu, 2008-09-25 at 21:02:12

  2. Thanks. I just checked and it appears svk is more common than I thought; it’s installed by default on Mac OSX. It is, however, not present on CMI and on MIT’s Athena machines, so I’ll postpone looking at it until the next time I have need for a DVCS :) [And by then, maybe git will be everywhere…]


    Thu, 2008-09-25 at 22:20:51

  3. For when it is everywhere,


    Fri, 2008-10-31 at 19:24:21

  4. @kittens: Awesome! Thank you.


    Tue, 2008-12-30 at 05:14:45

  5. the way you tell it makes it so easy. thanks.


    Sun, 2009-05-03 at 12:18:46

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: