gpt4 book ai didi

Git:重置 git 配置文件的最简单方法

转载 作者:IT王子 更新时间:2023-10-29 00:37:52 25 4
gpt4 key购买 nike

我终于开始学习 git 了。然而,我不明智地开始通过 Sourcetree 搞乱它(在我真正知道我在做什么之前)。现在我正在尝试完成它,我有一个相当大的设置列表。当我输入:

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

这似乎比我想开始的要多,因为我正在学习的教程并没有把所有这些都 pull 出来。

有没有办法将配置文件“重置”为默认状态?

最佳答案

请注意 git config --list两者都显示

  • 系统 ( <path/to/git/config> ),表示安装了 Git。
    (默认情况下,在 Windows 上:C:\Program Files\Git)
  • 全局($HOME/.gitconfig)。
    在 Windows 上,$HOME将是 %USERPROFILE%
  • 和本地 ( path/to/repo/.git/config) 设置。

要查看您已添加到您的存储库的那些:

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 更精确一些文件。


why git config --local --list doesn't show my proxy setting?

通常是因为可以在全局范围内为所有 存储库添加代理设置。

 git config --global --list

那将在 ~/.gitconfig 中或 %USERPROFILE%\.gitconfig .


注意:如果要删除特定值(不是正则表达式),请使用 Git 2.30(2021 年第一季度)

git config ”的各种子命令(man)需要value_regex了解“ --literal-value ”选项以获取 value_regex选项作为文字字符串。

参见 commit c902618 (2020 年 11 月 25 日)Junio C Hamano ( gitster ) .
参见 commit 3f1bae1 , commit c90702a , commit fda4394 , commit d156719 , commit 2076dba , commit 247e2f8 , commit 504ee12 (2020 年 11 月 25 日)Derrick Stolee ( derrickstolee ) .
(由 Junio C Hamano -- gitster -- merge 于 commit a10e784 ,2020 年 12 月 8 日)

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现在包含在其 man page 中:

--fixed-value

When used with the value-pattern argument, treat value-pattern asan exact string instead of a regular expression. This will restrictthe name/value pairs that are matched to only those where the valueis exactly equal to the value-pattern.

关于Git:重置 git 配置文件的最简单方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35853986/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com