22

I have a bare repo on remote location with some configs I'd like to share with everyone who clones it. Is it possible? Every time I clone, it seems to revert everything in .git/config to defaults and just add information about remote repo.

Ondrej Slinták
  • 31,386
  • 20
  • 94
  • 126

2 Answers2

24

I confirm a local config (the one within .git/config) is never shared amongst repo
(for various security reasons, like, for instance,:

  • a git alias which would define some commands only valid in your particular environment
    (or git commands themselves: no, as Jan Hudec comments, and as detailed in the question "Is it possible to override git command by git alias?")
  • some github directive (github.token) supposed to be secret and incorrectly entered in the local config instead of the global one
  • personal config like user.name and user.email (which can be set on a local level if those differs from other repos): that wouldn't make sense to propagate my name and email when other clone my repo.
  • ... ).

The closest way to do that would be to version an actual file with the config in it, and invite users to copy it in their .git/config file

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 3
    Actually aliases are not allowed to redefine existing commands. However your argument still stands; config indeed still gives too much control to be safe to distribute automatically. – Jan Hudec Jul 01 '11 at 13:06
  • @Jan: good point, I have included your comment in the answer, as well as a link to an older SO question which should have taught me that fact a year ago ;) – VonC Jul 01 '11 at 13:11
  • 1
    What about the config file of a "bare repository", i.e. generally a remote central repository? (more specifically I'm looking for the github default config settings) – KIAaze Sep 25 '12 at 08:54
  • @KIaze One could save-and-retrieve the remote configs from. special dedicated branch with some special programs for convenience. http://stackoverflow.com/a/21057383/94687 – imz -- Ivan Zakharyaschev Jan 11 '14 at 01:31
1

A .gitconfig file checked in is possible, but no great from a security perspective

Storing git config as part of the repository

Im still trying to figure it out, but I would also like to add an 'upstream' remote , and have that saved in the origin's repo... so users don't need to do git remote add on every clone...

Community
  • 1
  • 1
Kevin
  • 2,761
  • 1
  • 27
  • 31