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 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\.\([^=]*\)=\(.*\)/\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/ "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED" mergetool.sourcetree.trustexitcode=true user.name=My Name user.email= 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?
41 Answer
Note that git config --list does display both
- 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,$HOMEwould be%USERPROFILE% - and local (
path/to/repo/.git/config) settings.
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.
That is a bit more precise that just getting rid of the .git/config file.
why
git config --local --listdoesn't show my proxy setting?
Typically because a proxy setting could have been added for all repository, globally.
git config --global --list That would be in ~/.gitconfig or %USERPROFILE%\.gitconfig.
Note: if you want to remove a specific value (not a regex), use Git 2.30 (Q1 2021)
Various subcommands of "git config"(man) that takes value_regex learn the "--literal-value" option to take the value_regex option as a literal string.
See commit c902618 (25 Nov 2020) by Junio C Hamano (gitster).
See commit 3f1bae1, commit c90702a, commit fda4394, commit d156719, commit 2076dba, commit 247e2f8, commit 504ee12 (25 Nov 2020) by Derrick Stolee (derrickstolee).
(Merged by Junio C Hamano -- gitster -- in commit a10e784, 08 Dec 2020)
config: add--fixed-valueoption, un-implementedSigned-off-by: Derrick Stolee
The '
git config'(man) builtin takes a 'value-pattern' parameter for several actions.This can cause confusion when expecting exact value matches instead of regex matches, especially when the input string contains metacharacters. While callers can escape the patterns themselves, it would be more friendly to allow an argument to disable the pattern matching in favor of an exact string match.
Add a new '
--fixed-value' option that does not currently change the behavior.The implementation will be filled in by later changes for each appropriate action. For now, check and test that
--fixed-valuewill abort the command when included with an incompatible action or without a 'value-pattern' argument.The name '--fixed-value' was chosen over something simpler like '--fixed' because some commands allow regular expressions on the key in addition to the value.
git config now includes in its man page:
6
--fixed-valueWhen used with the
value-patternargument, treatvalue-patternas an exact string instead of a regular expression. This will restrict the name/value pairs that are matched to only those where the value is exactly equal to thevalue-pattern.