Like any other git repository, git-annex repositories have remotes. Let's start by adding a USB drive as a remote.
$ sudo mount /media/usb
$ cd /media/usb
$ git clone ~/annex
$ cd annex
$ git annex init "portable USB drive"
$ git remote add laptop ~/annex
$ cd ~/annex
$ git remote add usbdrive /media/usb/annex
This is all standard ad-hoc distributed git repository setup.
The only git-annex specific part is telling it a description of the new repository created on the USB drive. This is optional, but giving the repository a description helps when git-annex talks about it later.
Notice that both repos are set up as remotes of one another. This lets either get annexed files from the other. You'll often want to do that even when you are using git in a more centralized fashion.
Hi,
I have a laptop and desktop pc. I initialized git-annex repo on laptop and mounted laptop to desktop. I added mounted laptop directory to desktop as a remote. After I synced files with content with laptop on desktop. I want to get files and commits on laptop but I can't.
On laptop there is a .git directory but I don't know how to get files from it.
@elmimmo, you could add all those permutations, but there's no need to connect repositories that you don't need git-annex to transfer data between.
I see that you manually add the first repo as a remote of the external drive, and the external drive as a remote of the original.
What about when you add a second external drive? Should you then be adding the first two repos as remotes of the new one, and then go to the first two ones and add the new drive as a remote of them too? Doesn't this permutation scale out of control when you add a new drive to, say, a git annex made of 10 disks, 20 disks, etc?
Good spotting on the last line, fixed.
The laptop remote is indeed redundant, but it leads to clearer views of what is going on later in the walkthrough ("git pull laptop master", "(copying from laptop...)"). And if the original clone is made from a central bare repo, this reinforces that you'll want to set up remotes for other repos on the computer.
git remote add laptop ~/annex
? this remote already exists under the name origin.git remote add usbdrive /media/usb/annex
? because the actual repo would be in /media/usb/annex, not /media/usb?git annex fsck
complained that I had only one copy per file even though I had created my clone, already. Once Igit pull
ed from the second repo, not getting any changes for obvious reasons,git annex fsck
was happy. So I am not sure how my addition was incorrect. -- RichiH