How to define an alternative remote url for a git remote repository?
Asked Answered
E

2

10

I'm using git-annex to manage my files. Some of my remotes are available using 2 or 3 methods, for example ssh and nfs, but the nfs access is only possible on my local network, of course. Then, git-annex chooses the fastest method to sync or get the files (nfs, if available, ssh instead, using scores to choose). For now, I define a remote per repository and per access method (example: server-by-ssh, server-by-nfs), but that's not a really git-annex way to do the job, as it is not compliant with the numcopies option, which ckecks that the files in the annex are kept with enough replications (with my current method, many remotes are in fact the same folders on a hard drive).

Then, my question applies to both git and git-annex, since the remotes are added in git, not git-annex: I wonder if it is possible to define alternative url for a given remote.

I have tried to use the git remote set-url --add command, but it doesn't really work as I would expect. Indeed, if the nfs url is not reachable, git hangs up and waits.

Any idea?

Evince answered 21/8, 2012 at 9:4 Comment(2)
Is someone with a reputation high enough could add to that post a git-annex tag? Thanks!Evince
that's a new tag, so someone with over 1500 rep must create it. Anyone can add an existing tag to a question, but if their rep is not high enough it will be queued for review before being applied.Onomatology
E
6

I got the answer from the git-annex forum, where I had asked a question similar. It doesn't matter if there are many remotes pointing to the same repositories, using different accessing methods. Indeed, each repository gets an UUID when initialized by git-annex. Then, this UUID is associated to the remote when added and synced. Consequently, git-annex considers the different remotes that have the same UUID as a single repository.

Evince answered 21/8, 2012 at 18:22 Comment(1)
And, it seems there is no way to define alternative urls for remotes, that activate if the primary url is not reachable. At least, not directly with the standard git sotfware.Evince
A
5

You can add remote as

git remote add new-origin https://example.com/proj.git

Change value of existing remote

git remote set-url new-origin https://example-new.com/proj.git
Amplifier answered 21/8, 2012 at 11:53 Comment(3)
Sorry, but I do not need to change or add the origin. I want to define a primary url and a secondary url, in case the first one is not reachable, for the same repository. It is not the appropriate way to do that, right?Evince
@KingCrunch: I don't understand your edit and vote: this post is not the answer to the question, right? That method defines an alternative url, but if the first url is not reachable, git doesn't try the second one: it just waits for the first one. Or is there a timeout option that I'm not aware of?Evince
@Speredenn I only formatted the commands. You may have a look at the edit history.Desdamona

© 2022 - 2024 — McMap. All rights reserved.