2014-12-22 47 views
1

我觉得这个问题已经被解决过了,但是在找到一堆帖子后我找不到它。如何编辑我的Git配置?

我正在做一个关于Git的初学者教程。有人在我之前使用过这款Mac,并使用了多个Git应用程序(SourceTree等),它们似乎添加了各种配置偏好设置。

当我输入git config --list时,我得到一个巨大的列表(如下所示),不像我在Lynda.com上观看的教程,其中作者只显示user.name和user.email的列表。

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 
mergetool.sourcetree.cmd=--null 
user.name=username 
user.email=email 

最终,我想删除所有这些额外的设置。我尝试卸载Git,但这没有什么区别。有没有一个命令来撤销所有这些?任何帮助,将不胜感激。

+0

Mac OS X 10.10.1 – bboysupaman

回答

2

您的Git配置分布在多达三个配置文件(每个级别)。 您可以通过编辑这些文件或使用正确的git-config命令(更强大,但可能更繁琐)来编辑您的配置(添加/删除条目)。问题很简单,就是找到配置文件的哪个部分位于哪个配置文件中。而不是运行

git config --list 

其中列出了所有三个文件(即您整个的Git配置)的内容,你可以为每个列出这三个配置文件中的内容,运行三个不同的命令。

  • 系统级配置文件

    一般位于/usr/local/etc/gitconfig;至少,这就是我的Mac所在的地方(我用Homebrew安装了Git)。您可以通过运行列出其内容:通常位于$HOME/.gitconfig

    git config --system --list 
    
  • 用户级配置文件

    。您可以通过运行列出其内容:通常位于<repo-root-folder>/.git/config

    git config --global --list 
    
  • 库级配置文件

    。您可以通过运行列出其内容:

    git config --local --list 
    

如果你只想从你目前的配置保留user.nameuser.email领域,摆脱所有的休息,最简单的办法是删除所有三个配置文件,然后简单地运行

git config --global user.name <your-name> 
git config --global user.email <your-email> 

(该user.nameuser.email字段是最常在用户级的配置文件设置。)

+1

这就是我需要的!我能够将它缩小到正确的文件,并找到我需要摆脱的线条!谢谢! – bboysupaman