15

Let's say I create a symbolic link file inside an SVN managed path, commit the path to SVN, and later checkout the path.

  1. Will the symbolic link file survive?

  2. If the symbolic link file is made up of a relative path, will it work "everywhere" a checkout is done?

  3. Are there gotchas?

5 Answers 5

17

In general, Yes.

However, some clients don't work with symbolic links properly. Subclipse, for the Eclipse IDE, creates directories instead of symlinks.

So it's best to make sure your client is doing it right before getting into development.

4
  • Since I am a big user of Subclipse, this answer makes more sense for me.
    – jldupont
    Sep 29, 2009 at 17:58
  • Actually, Subclipse will create symlinks if you're checking out a working copy on Unix or Linux system--we use this all the time where I work (see John T's response).
    – bedwyr
    Oct 1, 2009 at 3:13
  • @bedwyr - I'm using Eclipse w/ subclipse at work - on a unix system (Snow Leopard) - and I get folders. Commandline works, other clients work, just not subclipse.
    – davethegr8
    Oct 1, 2009 at 22:38
  • I can't speak for Subclipse as I'm not a user of it, but from the command line, in at least version 1.6.11, I didn't have to do anything special to make it work. I created a symlink in a directory under version control, then committed it as normal. I a fresh checkout of the project the symlink was available and worked as normal. Jan 17, 2012 at 10:58
23

From the Subversion Features page:

Symbolic links can be versioned.

Unix users can place symbolic links under version control. The links are recreated in Unix working copies, but not in win32 working copies.

  1. Yes

  2. As long as permissions aren't changed, it should.

  3. Won't work on Windows checkouts.

5
  • 6
    stupid windows! Aug 12, 2010 at 11:33
  • 1
    although ntfs would support the feature ;) only nearly nobody knows it...
    – user375251
    May 31, 2012 at 13:32
  • Windows supports true symlinks through the mklink command, available since Vista
    – Brad Cupit
    Jul 22, 2014 at 12:48
  • I am not sure I understood your third point. Or perhaps I misread the question? If the symbolic link was created inside a managed path, I am suppose that SVN would think it is a directory/file, but not a link. So what is the problem with Windows — the symbolic link shouldn't appear in the repository at all!
    – Hi-Angel
    Feb 12, 2015 at 7:47
  • @FelipeAlvarez soft/hard links were never common in Windows because you would need to run a command (which most users don't know how to), and also administrator rights (until Windows 10). Besides explaining it to a normal user is like explaining how pointer works in C which may not be easy to understand
    – phuclv
    Jun 11, 2017 at 11:36
8

Symlinks won't survive on a Windows machine, this can be a problem.
On Windows machines the symlinks take the form of placeholder files*), for example:

style.css:

link ../www_public/styles.css

*): these files have "svn:special" propery with a value of "*".

I sometimes have to export stuff to a windows machine before I can move/upload the project to it's destination server.

I use a small shell script that does a wonderful job at recreating the actual symlinks from the placeholder files:

#!/bin/sh

grep -lr '^link ' . | while read placeholderfile
do
  linecount=`wc -l $placeholderfile | cut -c1`
  if [ $linecount -eq 0 ] ; then
    linkfile=`cut -c6- "$placeholderfile"`
    ln -sf "$linkfile" "$placeholderfile"

    echo -e "[\E[32;40mOK\E[37;40m] Replaced $placeholderfile with symlink"
  else
    echo -e "[\E[31;40mWARNING\E[37;40m] $placeholderfile contains newline(s)"
  fi
  tput sgr0
done

This script works on the assumption that all files that start with the string "link" and do not contain newlines are symlinks.

1

From Windows 7 onwards, the OS understands symbolic links; see here for some documentation. The regular SVN clients under Windows do not yet support this, but svn under cygwin does!

0

NTFS supports symlinks from the very beginning - this is a legacy of the POSIX sub-system of NT. So you can create symlinks. But Windows as OS can recognize symlinks as such only from Win 7 onwards. And they are restricted - by default policy, normal users cannot create symlinks with MKLINK.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .