Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: Easiest way to reset git config file

Tags:

git

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/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?

like image 330
bboysupaman Avatar asked Mar 07 '16 21:03

bboysupaman


People also ask

How do I change my git config file?

The global git config is simply a text file, so it can be edited with whatever text editor you choose. Open, edit global git config, save and close, and the changes will take effect the next time you issue a git command. It's that easy.

What is hard reset git?

Summary. To review, git reset is a powerful command that is used to undo local changes to the state of a Git repo. Git reset operates on "The Three Trees of Git". These trees are the Commit History ( HEAD ), the Staging Index, and the Working Directory.


1 Answers

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, $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 

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 --list doesn'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-value option, un-implemented

Signed-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-value will 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:

--fixed-value

When used with the value-pattern argument, treat value-pattern as 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 the value-pattern.

like image 68
VonC Avatar answered Sep 20 '22 08:09

VonC