Re: ~/.git/config ?
From: Linus Torvalds <torvalds@osdl.org>
Date: 2016-06-15 22:42:27
On Sat, 27 May 2006, Petr Baudis wrote:
~/.gitrc might get useful for actually doing what ~/.cvsrc or ~/.cgrc does, that is providing default options for git commands. ~/.gitconfig would just give you per-user defaults for the repository config file.
I don't think the two are necessarily any different.
I do think that
(a) we might as well use the same syntax. There's no point in having
different syntax for the files, even if they end up having slightly
different usage.
(b) a "user-wide" config file would tend to have different things in it
than a per-repository one, but some of the things it would have in it
are the things that we currently put in the per-repository one.
Notably exactly the "user.name" and "user.email" values.
(c) having a user- (and perhaps a system-) wide config file would make
some things that we do not _yet_ support in the .git/config file
format more natural, but that doesn't necessarily mean that having
them on a per-repo basis would be wrong either.
As an example of (c), let's say that somebody wants to use the CVS aliases
with git. They've used cvs for years, and as a result their brain has
atrophied, and they have a really hard time teaching their fingers to
write "git commit" when they want to write "cvs ci".
So they would do "alias cvs git" in a desperate attempt to save themselves
from CVS, and then add
[alias "co"]
cmd = commit -a
to their .gitrc file. Now, the only thing we'd need to do is to teach
"git.c" to parse that simple "alias.$1.command" variable, and that really
sounds pretty damn easy, no?
And that really does make more sense in a user-wide ".gitrc" file. But at
the same time, there's really no reason to _disallow_ it from the
repo-private .git/config file either. For example, you could do
[alias "publish"]
cmd = push public.site.com:/pub/scm/my-public-repo
and that is somethign that actually makes sense as a per-repository
command alias, so that "git publish" does the right thing for just _that_
repository.
So I would argue that yes, ".gitrc" makes sense, and no, we shouldn't have
a separate ".gitrc" and ".gitconfig", because I think what we really would
want is a way to do default .git/config entries, and that it is _also_ a
very natural way to add some things that we don't do yet.
Linus
PS. I really like my [alias "cmd"] idea. _All_ my ideas are great, of
course, but this one seems even better than some others. No?