新git存储库的默认配置设置?

时间:2010-01-19 11:29:40

标签: git configuration

当我创建新的git存储库时,一些配置设置会自动添加到 .git / config 。我在哪里可以更改这些默认设置?

2 个答案:

答案 0 :(得分:13)

考虑git init的选项模板:

 --template=<template_directory>
  

提供将使用模板的目录。默认模板目录为/usr/share/git-core/templates

     

指定后,<template_directory>将用作模板文件的来源,而不是默认值   模板文件包括一些目录结构,一些建议“排除模式”,以及非执行“钩子”文件的副本。建议的模式和钩子文件都是可修改和可扩展的。

如果查看creating a new db的git源代码,可以在其中包含一个默认值的配置文件。

function create_default_files()确实有:

 /* First copy the templates -- we might have the default
  * config file there, in which case we would want to read
  * from it after installing.
  */
copy_templates(template_path);

git/config.c具有设置默认值的git_default_core_config()函数。

答案 1 :(得分:1)

所有git全局配置都可以通过命令行提供的--global进行更改。

例如:

git config --global user.name "First Last"
git config --global user.email "email@somewhere.com"

更新

可以找到所有现有的git配置
git config -l

此外,git config -e会打开一个编辑器进行编辑。

相关问题