0

I have a code repo that has multiple remotes, and the remotes were configured locally on my computer.

After pushing the code to origin and having a colleague pull the code, I have to set up the list of remotes again.

Is there a way to include the .git/config file as part of the repo's commits? If not, would be happy to hear other recommendations too.

FYI, I've tried both adding the include path as suggested here as well as adding the !filename line to .gitignore, to no effect.

Thanks ahead for your help/suggestions.

Community
  • 1
  • 1
DevChefOwen
  • 75
  • 1
  • 2
  • 6

1 Answers1

2

You cannot include files inside your .git repository in the repository itself. The ability to do so would be a substantial security risk, because it would permit someone to -- for example -- install scripts into your .git/hooks directory, or simply corrupt your local repository. So yeah, that would be a terrible idea.

An easier solution is to include a script in your repository that your colleague can run that will set up the necessary remotes. That is, create a script called something like update-remotes, and have it run a series of git remote add commands. Include that script in your repository as well as instructions for running it.

larsks
  • 277,717
  • 41
  • 399
  • 399
  • This makes sense, thanks larsks. Follow-up question: our team develops with from multiple OSes, and I don't think a script would work across OSX, Windows, Linux boxes. Any thoughts on a unified way of doing this? – DevChefOwen Mar 25 '15 at 18:20
  • Additionally, the idea of adding scripts into a repo which is basically pure code that we would directly push to a server seems foreign to me. I get the feeling this is something to read further up on, any resources would be appreciated. – DevChefOwen Mar 25 '15 at 18:23
  • Whereas the idea of adding a script to a repo in order to assist with common setup operations (adding remotes, creating pre-commit hooks, etc) seems perfectly natural to me. I don't have any references for you; either include a document that describes that manual process people must use to set up the necessary remotes, or you include a script to automate it. You could produce a script *external* to the repository that would perform the initial clone and set up the remotes. A script containing only `git` commands would run fine on OSX, Windows, and Linux, provided the `git` CLI was available. – larsks Mar 25 '15 at 18:32