重置 git 配置文件的最简单方法
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35853986/
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
Easiest way to reset git config file
提问by bboysupaman
I am finally getting around to learning git. However, I unwisely started messing around with it awhile back (before I really knew what I was doing) via Sourcetree. Now that I'm trying to go through it, I have a pretty large list of settings. When I input:
我终于开始学习 git 了。然而,不久前(在我真正知道自己在做什么之前),我不明智地开始通过 Sourcetree 弄乱它。现在我正在尝试通过它,我有一个相当大的设置列表。当我输入:
git config --list
I get the following result:
我得到以下结果:
core.excludesfile=~/.gitignore
core.legacyheaders=false
core.quotepath=false
core.pager=less -r
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\.\([^=]*\)=\(.*\)/\ => /' | sort
include.path=~/.gitcinclude
include.path=.githubconfig
include.path=.gitcredential
diff.exif.textconv=exif
credential.helper=osxkeychain
core.excludesfile=/Users/myusername/.gitignore_global
difftool.sourcetree.cmd=opendiff "$LOCAL" "$REMOTE"
difftool.sourcetree.path=
mergetool.sourcetree.cmd=/Applications/SourceTree.app/Contents/Resources/opendiff-w.sh "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED"
mergetool.sourcetree.trustexitcode=true
user.name=My Name
[email protected]
And that seems like more than what I want to start with since the tutorial that I'm working through doesn't pull all of that up.
这似乎比我想要开始的更多,因为我正在学习的教程并没有把所有这些都拉上来。
Is there a way to "Reset" the config file to a default state?
有没有办法将配置文件“重置”为默认状态?
采纳答案by VonC
Note that git config --list
does display both
请注意,git config --list
确实同时显示
- the system (
<path/to/git/config>
), meaning where Git has been installed.
(By default, on Windows:C:\Program Files\Git
) - global (
$HOME/.gitconfig
).
On Windows,$HOME
would be%USERPROFILE%
- and local (
path/to/repo/.git/config
) settings.
- 系统 (
<path/to/git/config>
),表示 Git 的安装位置。
(默认情况下,在Windows上:C:\Program Files\Git
) - 全局 (
$HOME/.gitconfig
)
在 Windows 上,$HOME
将是%USERPROFILE%
- 和本地 (
path/to/repo/.git/config
) 设置。
To see the ones you have added to your repo:
要查看您添加到存储库中的那些:
git config --local --list
To remove multiple values:
删除多个值:
git config [<file-option>] --unset-all name [value_regex]
git config [<file-option>] --remove-section name
For instance: git config --local --remove-section alias
would get rid of the aliases.
例如:git config --local --remove-section alias
将摆脱别名。
That is a bit more precise that just getting rid of the .git/config
file.
这比删除.git/config
文件更精确。
why
git config --local --list
doesn't show my proxy setting?
为什么
git config --local --list
不显示我的代理设置?
Typically because a proxy setting could have been added for allrepository, globally.
通常是因为可以为所有存储库全局添加代理设置。
git config --global --list
That would be in ~/.gitconfig
or %USERPROFILE%\.gitconfig
.
那将在~/.gitconfig
或 中%USERPROFILE%\.gitconfig
。