forum/Multiple repos on same pathgit-annexhttp://git-annex.branchable.com/forum/Multiple_repos_on_same_path/git-annexikiwiki2015-07-20T17:43:05ZCreate symlink in the root directoryhttp://git-annex.branchable.com/forum/Multiple_repos_on_same_path/comment_1_67ed823c4c40f5acf12b48eb75d7afa8/sunny2562015-05-12T13:04:18Z2015-05-12T13:04:18Z
<p>My way of dealing with this is to create a symlink in the root directory that point to the root directory, like</p>
<div class="highlight-sh"><pre class="hl">$ <span class="hl kwb">cd</span> <span class="hl opt">/</span>
$ sudo <span class="hl kwc">ln</span> <span class="hl kwb">-sv</span> . compname
<span class="hl opt">[</span>sudo<span class="hl opt">]</span> password <span class="hl kwa">for</span> sunny<span class="hl opt">:</span> hunter2
<span class="hl str">'compname'</span> <span class="hl opt">-></span> <span class="hl str">'.'</span>
$ <span class="hl kwc">ls</span> <span class="hl kwb">-l</span> compname
lrwxrwxrwx <span class="hl num">1</span> root root <span class="hl num">1</span> May <span class="hl num">12 14</span><span class="hl opt">:</span><span class="hl num">52</span> compname <span class="hl opt">-></span> .
$
</pre></div>
<p>where <code>compname</code> is the hostname for the computer. Now you can create paths like</p>
<div class="highlight-sh"><pre class="hl">git remote add comp-a <span class="hl opt">/</span>comp-a<span class="hl opt">/</span>home<span class="hl opt">/</span>my_user<span class="hl opt">/</span>data<span class="hl opt">/</span>repo
git remote add comp-b <span class="hl opt">/</span>comp-b<span class="hl opt">/</span>home<span class="hl opt">/</span>my_user<span class="hl opt">/</span>data<span class="hl opt">/</span>repo
</pre></div>
<p>This is also useful in other scripts where fetching data from the right directory on the wrong computer is bad. Also, this is a cheap way for a script to determine which computer it's running on:</p>
<div class="highlight-sh"><pre class="hl"><span class="hl kwb">test -L</span> <span class="hl str">"/comp-a"</span> <span class="hl opt">&&</span> <span class="hl kwb">echo</span> Running on computer comp-a
</pre></div>
comment 2http://git-annex.branchable.com/forum/Multiple_repos_on_same_path/comment_2_e1c4ac71eb0f9ff6ae1701b3a6d738dd/joey2015-07-20T17:43:05Z2015-07-20T17:38:10Z
<p>sunny256 has a nice approach with the symlinks to make the paths
to the remores explicitly contain the machine name.</p>
<p>However, if you want to keep it simple, it's perfectly fine for a
remote's path to point to a directory which has different
repositories mounted on it at different times. I do this in my own
removable media drives, so the "host" remote uses /home/joey/sound,
for example.</p>
<p>This is safe to do because git-annex always checks the UUID of the
remote before using it. For a local path like this, it will automatically
update the cached annex-uuid of the remote when it finds a repo with a
different UUID mounted. (For a path to a repo on a remote server, it uses
other methods to verify that it's accessing the repo with the UUID it
expected.)</p>
<p>The only thing I'd be careful about doing is switching the repository that
is mounted at a path with another one while git-annex is running, since it
only checks at startup and won't notice the substitution and could get
confused.</p>