git-annex/ walkthrough/ adding a remote

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.

comment 7

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.

Comment by slackermesut — Wed Oct 29 14:05:27 2025
comment 6

@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.

Comment by joey — Wed Oct 29 14:05:27 2025
Remotes when using multiple repos

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?

Comment by elmimmo — Wed Oct 29 14:05:27 2025
comment 4

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.

Comment by http://joey.kitenet.net/ — Wed Oct 29 14:05:27 2025
comment 3

- why the `git remote add laptop ~/annex` ? this remote already exists under the name origin.
- doesn't the last command need to be `git remote add usbdrive /media/usb/annex`? because the actual repo would be in /media/usb/annex, not /media/usb?

Comment by http://dieter-be.myopenid.com/ — Wed Oct 29 14:05:27 2025
comment 2
Yes, you have to pull down location tracking information in order for fsck to be satisfied in that situation. But since this is a walkthrough, and neither fsck or numcopies settings are mentioned until later, it's ok for this pull to be described a few steps along in getting file content.
Comment by http://joey.kitenet.net/ — Wed Oct 29 14:05:27 2025
comment 1
After doing the above with two required copy per file, `git annex fsck` complained that I had only one copy per file even though I had created my clone, already. Once I `git 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
Comment by https://www.google.com/accounts/o8/id?id=AItOawl9sYlePmv1xK-VvjBdN-5doOa_Xw-jH4U — Wed Oct 29 14:05:27 2025
Comments on this page are closed.