0

I'm pretty sure I know the answer to this, can I "preset" (i.e., commit) a remote to a Git repository so that when it is cloned, the cloned repository also has the remote without having to remote add it?

Here's the use case. I want to fork node and make changes that only my team needs (i.e., that would be inappropriate to merge back into the upstream repository). I also want my team to be able to periodically merge new changes from the original repository. In other words:

  1. On github.com: fork github.com/joyent/node → github.com/[me]/node
  2. On my local machine: git clone https://github.com/[me]/node.git
  3. On my local machine: git add remote upstream https://github.com/joyent/node.git
  4. [branch, hack, merge, fetch upstream, push, etc.]...

So far so good.

What I really want is to "commit" and "push" the upstream remote configuration so the next time someone does git clone https://github.com/[me]/node.git, they don't have to also do git add remote upstream https://github.com/joyent/node.git (i.e., it's already set for the cloned repository).

I see that git has a specialized notion of being able to commit submodule configurations (see gitmodules[5]), but I can't find a generic option for arbitrary configuration overrides. I realize this is probably by design, since it risks misuse (imagine a preset override of user.email).

Any help is appreciated, even if it's just: "Nope, sorry. Your team is going to have to type git add remote upstream ... for every cloned repo. [Citation.]"

posita
  • 864
  • 1
  • 9
  • 17

1 Answers1

0

Literally minutes after submitting this question, I found this question and answer (which I didn't find in my initial search).

Basically, it says that git add remote upstream ... must be run, (or .git/config must be edited) for every cloned repo. As @AndrewC points out, this can be automated with a [wrapper] script.

This seems clunky to me, but I will accept that fixing upstream remotes is probably a bad idea.

posita
  • 864
  • 1
  • 9
  • 17