2

I would like to include a secondary remote in a git repository so that when a user clones the repo, it automatically adds the second remote. So it could have the following after cloning:

> git remote -v
origin  https://something.gitlab.com/user/test.git
remote2  ssh://server.location.com:/path/to/source/.git

Is there a mechanism in git to do this?

Note: git annex has an autoenable option that does this for it's special remotes. This is where I got the idea. Ref: https://git-annex.branchable.com/git-annex-init/

ted.strauss
  • 4,119
  • 4
  • 34
  • 57
  • 1
    Looks like your best options is to use templates. Create a post-checkout hook. https://stackoverflow.com/questions/2141492/git-clone-and-post-checkout-hook – EncryptedWatermelon Oct 03 '19 at 17:26

1 Answers1

1

git does not provide such functionality. FWIW, I would not want it to; IMO repos should not be able to manipulate my configuration just because I clone them.

Note that the command you linked does not execute on cloning; it executes on running a command to initialize git-annex within an already-initialized repo that doesn't forbid enabling it. This is analogous to including in your repo a script that will add the remote if the user chooses to execute it - not analogous to automatically doing it "for" them (whether they want you to or not) on clone

Mark Adelsberger
  • 42,148
  • 4
  • 35
  • 52