git 找不到 gitconfig 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32538639/
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
Cannot find gitconfig file
提问by elnurcoot
I just started learning about Linux and Git. Im using Linux Mint. I have Git and emacs installed via apt-get.
我刚刚开始学习 Linux 和 Git。我使用 Linux Mint。我通过 apt-get 安装了 Git 和 emacs。
Im using the following tutorial https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup
我使用以下教程 https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup
it says that there are configuration files in three different places:
它说在三个不同的地方有配置文件:
/etc/gitconfig
file~/.gitconfig
or~/.config/git/config
file- config file in the Git directory (that is, .git/config) of whatever repository you're currently using.
/etc/gitconfig
文件~/.gitconfig
或~/.config/git/config
档案- 您当前使用的任何存储库的 Git 目录(即 .git/config)中的 config 文件。
I have just started with Git so assume that option 3) is not applicable
我刚刚开始使用 Git,所以假设选项 3) 不适用
I checked both 1) and 2) - i just cannot locate the files anywhere
我检查了 1) 和 2) - 我只是无法在任何地方找到文件
I googled this with no luck and did sudo find . -name
in the root directory
我在没有运气的情况下用谷歌搜索了这个并sudo find . -name
在根目录中做了
Have no clue what is happening as when i run this
不知道当我运行这个时发生了什么
$ git config --global user.name "John Doe"
$ git config --global user.email [email protected]
(i used my name surname above obviously)
(我显然在上面使用了我的名字姓氏)
it doesn't give me an error or anything - so where does it write this config data then?? where are these files?
它没有给我一个错误或任何东西 - 那么它在哪里写这个配置数据呢??这些文件在哪里?
采纳答案by VonC
As confirmed by the OP, any git config --global
command will create/update ~/.gitconfig
.
正如 OP 所确认的那样,任何git config --global
命令都将 create/update ~/.gitconfig
。
But as it is an hidden file by default, you would need a ls -alrt
to see it.git config --global -l
will list its content.
但由于默认情况下它是一个隐藏文件,您需要ls -alrt
查看它。git config --global -l
将列出其内容。
More generally, git config --list --show-origin
shows all config files (and each line of the config data).
With Git 2.26 (Q1 2020), you can add a --show-scope
option
更一般地,git config --list --show-origin
显示所有配置文件(以及配置数据的每一行)。
使用 Git 2.26(2020 年第一季度),您可以添加一个--show-scope
选项
git config --list --show-origin --show-scope
That will also print the scope ("local
", "global
", etc) of all displayed config values.
这还将打印所有显示的配置值的范围(“ local
”、“ global
”等)。
回答by BinaryJoe01
To find your global .gitconfig
file:
要查找您的全局.gitconfig
文件:
- Open your terminal or command prompt
- Go to your root directory by typing
cd ~
- Once in your root folder type
ls -alrt
- You will see a
.gitconfig
file- To open your
.gitconfig
file typeopen .gitconfig
- To open your
- 打开终端或命令提示符
- 通过键入转到您的根目录
cd ~
- 一旦进入您的根文件夹类型
ls -alrt
- 你会看到一个
.gitconfig
文件- 打开您的
.gitconfig
文件类型open .gitconfig
- 打开您的
To find a particular repository's .gitconfig
file:
要查找特定存储库的.gitconfig
文件:
- Open your terminal or command prompt
- Go to your repository'sroot directory by typing
cd path/to/repository-directory
- Once in your repository's root directory type
ls -alrt
- You will see a
.git
directory. Typecd .git
- Once in your repository's
git
directory typels -alrt
- You will see a
config
file- To open your repository's
.gitconfig
file typeopen config
- To open your repository's
- 打开终端或命令提示符
- 通过键入转到存储库的根目录
cd path/to/repository-directory
- 一旦进入存储库的根目录类型
ls -alrt
- 你会看到一个
.git
目录。类型cd .git
- 一旦进入存储库的
git
目录类型ls -alrt
- 你会看到一个
config
文件- 打开存储库的
.gitconfig
文件类型open config
- 打开存储库的
回答by Help Out
I got my config file by using git config --system --list
我通过使用获得了我的配置文件 git config --system --list