I have some project, which I share with other people. It is stored and distributed in git.

It should contain links to directories outside the git archive, but inside th user home, where some common libraries are, like this:

Arduino -> /home/gilhad/GitHub/arduino-1.8.1
Arduino-Makefile -> /home/gilhad/GitHub/Arduino-Makefile
Bare-Arduino-Project -> /home/gilhad/GitHub/Bare-Arduino-Project

It works for me (gilhad), but does not work for my friend. I would like to make links like this:

Arduino -> ~/GitHub/arduino-1.8.1
Arduino-Makefile -> ~/GitHub/Arduino-Makefile
Bare-Arduino-Project -> ~/GitHub/Bare-Arduino-Project

which would effectively resolve to the previous on my account and to following on friends account

Arduino -> /home/friend/GitHub/arduino-1.8.1
Arduino-Makefile -> /home/friend/GitHub/Arduino-Makefile
Bare-Arduino-Project -> /home/friend/GitHub/Bare-Arduino-Project

(regardless where this git/actual directory is actually placed , so ../../../GitHub/.... as target would not work, as the project can be placed in ~/tmp as well as in ~/my/special/folder/for/projects, while GitHub is always placed in users home direcory (/home/gilhad or /home/friend or what ~ points to)

  • 1
    Add a simple setup script that creates the links.
    – Kusalananda
    Commented Mar 16, 2017 at 8:35
  • I see no way. The links are a file system thing, while ~ is a shell thing. The file system doesn't know what ~ is. I wonder why the other people can be forced to put the GitHub at a fixed location, but not the repo.
    – Philippos
    Commented Mar 16, 2017 at 8:41
  • It is always possibility, but if the symlinks could be solved somehow better it would be more elegant. I tried ln -s '~/GitHub/arduino-1.8.1' A2 where ls -al shows A2 -> ~/GitHub/arduino-1.8.1 in red and A2 looks like broken link
    – gilhad
    Commented Mar 16, 2017 at 8:43
  • GitHub is used to sit in users home as our convence and everybody have there some projects from github (some common, some special for the user), the repo can travel. For example I have the repo usually uder ~/GIT/common_projects directory, but often copy/clone it to ~/tmp for some wild experiments, use it there for a day or two and delete it later, or merge with official depending on result (I know about branches, but when I try to rearrange history and fail, or something like that.. or just want to use 'copy' of the project to run some tests in the same environment and delete them later)
    – gilhad
    Commented Mar 16, 2017 at 8:50

1 Answer 1


You can't really do that with symbolic links. In addition to the fact that referring to the home directory with a tilde is a shell feature, and not supported by all programs (though many do), the whole concept of a "home directory" is a user-space concept, and doesn't exist in the kernel. So the kernel's filesystem layer, which resolves symbolic links, doesn't have the knowledge you need.

On Linux, you could rig something up with mount namespaces and bind mounts, if you really wanted. (see here, here and here)

In any case, the idea of creating links in a git repository that point outside the repository itself seems a bit odd to me. Using the links will be possible only for those who conform to the system set by the links, and a single user who wants to / has a need for a different layout, is a bit out of luck. You might want to consider using, say environment variables to store the locations of the users' files. Say with $ARDUINO pointing to /home/foo/GitHub/arduino-1.8.1 or /home/foo/GitHub/arduino-someotherversion as the user requires.

  • What I would need is unix.stackexchange.com/questions/1806/… and it says it does not exist. So I will go with install script as @Kusalananda suggested for now and re-think the all setup later. Tahnk for your guidance anyway :)
    – gilhad
    Commented Mar 16, 2017 at 9:57

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