Easiest way to reset git config file

后端 未结 1 1123
闹比i
闹比i 2021-02-02 09:57

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

相关标签:
1条回答
  • 2021-02-02 10:17

    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.

    0 讨论(0)
提交回复
热议问题