在哪里可以找到/创建用于项目本地配置的 .git/config 文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25978057/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Where to find/create .git/config file for local configuration for project?
提问by darkBlastorise
I want to know how I can create/find a .git/config file for my project, as windows does not allow me to put the "/". Also, is this a file or is it a folder?
我想知道如何为我的项目创建/查找 .git/config 文件,因为 Windows 不允许我放置“/”。另外,这是一个文件还是一个文件夹?
Is there a difference between .gitconfig and .git/config?
.gitconfig 和 .git/config 之间有区别吗?
回答by Abhishek
Yes, there is difference between .gitconfig
and .git/config
.
是的,.gitconfig
和之间有区别.git/config
。
.git/config
will have the configuration details of your repository. But .gitconfig
will have your user details and the configuration you set for git like user.name
, user.email
, default editor, color setting, etc.
.git/config
将包含您的存储库的配置详细信息。但是,.gitconfig
将有你的用户细节和配置你像git的设置user.name
,user.email
默认编辑器,颜色设置等。
In Windows, you will find the .gitconfig
file in C:\Users\user_name
.
在 Windows 中,您将.gitconfig
在C:\Users\user_name
.
.git/config
file can be located under <git_repository>/.git/
(.git/config
gets created once you run git init
command or you clone an initialized repository).
.git/config
文件可以位于<git_repository>/.git/
(.git/config
运行git init
命令或克隆初始化存储库后创建) 下。
回答by Mudassir Razvi
.gitconfig
is a global configuration file that resides in your HOMEDIR.
.gitconfig
是驻留在 HOMEDIR 中的全局配置文件。
.git
is your special directory in any git repo that makes it a 'repo'.
.git
是任何 git repo 中的特殊目录,使其成为“repo”。
Inside .git is a file called config
that applies all the configurations mentioned in it to that particular repository only.
.git 内部是一个名为的文件config
,它仅将其中提到的所有配置应用于该特定存储库。
You can add configurations to either .gitconfig/.git/config using the git config
command.
您可以使用git config
命令将配置添加到 .gitconfig/.git/config 。
Eg:
git config user.name "Jane Doe"
adds a user.name entry in your current repository's .git/config file
例如:
git config user.name "Jane Doe"
在当前存储库的 .git/config 文件中添加一个 user.name 条目
git config --global user.email "[email protected]"
adds a user.email entry in your users .gitconfig file, and it will be applicable to all repos under that users.
(Note use of --global)
git config --global user.email "[email protected]"
在您的用户 .gitconfig 文件中添加一个 user.email 条目,它将适用于该用户下的所有存储库。(注意 --global 的使用)
Using mysysgit has a lot of benefits. Cygwin is also a good option!
使用 mysysgit 有很多好处。Cygwin 也是一个不错的选择!
Cheers!
干杯!
回答by Lovato
.gitconfig holds all your git configuration for your machine. On each repository, there is a .git folder, and inside it, you can find a config file, which holds information for this particular repo.
.gitconfig 保存您机器的所有 git 配置。在每个存储库上,都有一个 .git 文件夹,您可以在其中找到一个配置文件,其中包含此特定存储库的信息。
I recommend, under Windows, to use msysgit, a improved cmd line tool to work with Git.
我建议在 Windows 下使用 msysgit,这是一个改进的 cmd 行工具来处理 Git。
回答by love
Actually Git stores configuration options in three separate files, which lets you scope options to individual repositories, users, or the entire system:
实际上,Git 将配置选项存储在三个单独的文件中,这使您可以将选项范围限定为单个存储库、用户或整个系统:
repo/.git/config – Repository-specific settings
~/.gitconfig – User-specific settings
This is where options set with the --global flag are stored.
git config --global user.name "Love"
git config --global user.email [email protected]
$(prefix)/etc/gitconfig – System-wide settings.
repo/.git/config – 特定于存储库的设置
~/.gitconfig – 特定于用户的设置
这是存储使用 --global 标志设置的选项的位置。
git config --global user.name "爱"
git config --global user.email [email protected]
$(prefix)/etc/gitconfig – 系统范围的设置。