首页 > 解决方案 > Git 配置 (git config --list) 我可以删除什么以及如何删除?

问题描述

我正在努力使用终端学习 Git,但我不得不说我还没有走远。所以任何帮助都会很有用。我用同样的问题(链接)阅读了这个线程,但我无法解决它。此外,我还有一个菜鸟问题。

就这样吧。在安装 git 并执行 git config --user.name 和 --user.email 之后,我开始编写 git config --list 以查看预先配置的内容。我发现了所有这些:

core.excludesfile=~/.gitignore
core.legacyheaders=false
core.quotepath=false
mergetool.keepbackup=true
push.default=simple
color.ui=auto
color.interactive=auto
repack.usedeltabaseoffset=true
alias.s=status
alias.a=!git add . && git status
alias.au=!git add -u . && git status
alias.aa=!git add . && git add -u . && git status
alias.c=commit
alias.cm=commit -m
alias.ca=commit --amend
alias.ac=!git add . && git commit
alias.acm=!git add . && git commit -m
alias.l=log --graph --all --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s %C(white)- %an, %ar%Creset'
alias.ll=log --stat --abbrev-commit
alias.lg=log --color --graph --pretty=format:'%C(bold white)%h%Creset -%C(bold green)%d%Creset %s %C(bold green)(%cr)%Creset %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
alias.llg=log --color --graph --pretty=format:'%C(bold white)%H %d%Creset%n%s%n%+b%C(bold blue)%an <%ae>%Creset %C(bold green)%cr (%ci)' --abbrev-commit
alias.d=diff
alias.master=checkout master
alias.spull=svn rebase
alias.spush=svn dcommit
alias.alias=!git config --list | grep 'alias\.' | sed 's/alias\.\([^=]*\)=\(.*\)/\1\     => \2/' | sort
include.path=~/.gitcinclude
include.path=.githubconfig
include.path=.gitcredential
diff.exif.textconv=exif
credential.helper=osxkeychain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
user.name=myusername
user.email=“myemail”
user.name=“myname
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true

现在,在我发送之前的链接中,它解释了为什么所有内容都是预先配置的,但我希望从头开始并从底部学习。当我在终端中写: ls -a 时,我找到了 .gitconfig 文件和 .git 目录。这两者有什么区别?当我打开 .gitconfig 我发现这个

[filter "lfs"]
    clean = git-lfs clean -- %f
    smudge = git-lfs smudge -- %f
    process = git-lfs filter-process
    required = true
[user]
    name = myusername
    email = “myemail”
    name = “myname

当我去 cd .git 时,我发现更多文件,其中包括配置,当我打开这个文件时,这就是它显示的内容。

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true

我不想犯错误,在我之前提到的帖子中说“你可以删除所有这些,如果你愿意,可以开始清理。” 我究竟需要擦除什么?一切?

我还有一个小问题会让我看起来很愚蠢,但它就是这样。当终端想要显示长列表时,我有时会使用“向下箭头”查看所有内容,有时会显示“END”退出按钮,但随后显示“ESC”,然后再次被阻止。我的菜鸟解决方案是关闭终端并重新开始。在这些事件中我应该怎么做?

在此处输入图像描述

无论如何,感谢您花时间阅读本文!

标签: gitconfig

解决方案


Git 的配置系统是分层的:系统本身有一个配置(通常是/etc/gitconfig),您作为用户有一个配置(通常在~/.gitconfig,您的主目录中名为 的文件),并且您单独创建的每个 git 存储库在其目录.gitconfig中都有自己的文件. 这意味着系统可以具有您单独覆盖的整体设置,然后您可以在您使用的单个存储库中覆盖它们。您可以在帮助页面的各个部分下查看各个路径。config.gitgitFILESgit config

如果你想查看这些设置是在哪里配置的,你可以使用git config --list --show-origin这个问题:How to find out which Git config file is used and how to override settings?. 该问题还涉及有关这些配置层次结构级别如何工作的一些细节。

您的问题(END)与“寻呼机”有关,该程序是一个运行程序,可让您使用光标以交互方式阅读长文档。Git 在默认情况下经常使用分页器,您可以通过环境变量或core.pager配置来使用(或完全禁用它们)哪个分页器。(请参阅文档git config)调用了一个常见的默认寻呼机less,它有自己的有用man页面,但重要的部分是您可以使用该字母h打开帮助并q退出程序


推荐阅读