问题描述
我终于可以开始学习git了.但是,我不明智地开始通过Sourcetree回想一下(在我真正知道自己在做什么之前).现在,我正在尝试通过它,我有一个很大的设置列表.当我输入:
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 config --list
我得到以下结果:
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\.\([^=]*\)=\(.*\)/\1\ => \2/' | 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
user.email=myemail@email.com
这似乎比我想开始做的要多,因为我正在研究的教程并没有把所有这些都考虑在内.
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?
推荐答案
请注意,git config --list
确实显示了两者
Note that git config --list
does display both
- 系统(
<path/to/git/config>
),表示已安装Git的位置.
(默认情况下,在Windows上:C:\Program Files\Git
) - 全局(
$HOME/.gitconfig
).
在Windows上,$HOME
为%USERPROFILE%
- 和本地(
path/to/repo/.git/config
)设置.
- 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.
要查看已添加到存储库中的文件:
To see the ones you have added to your repo:
git config --local --list
要删除多个值:
git config [<file-option>] --unset-all name [value_regex]
git config [<file-option>] --remove-section name
例如:git config --local --remove-section alias
将消除别名.
这比删除.git/config
文件更为精确.
That is a bit more precise that just getting rid of the .git/config
file.
通常是因为可以为全局 all 存储库添加代理设置.
Typically because a proxy setting could have been added for all repository, globally.
git config --global --list
应该在~/.gitconfig
或%USERPROFILE%\.gitconfig
中.
这篇关于重置git配置文件的最简单方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!