In my git config I have many url.
sections where I have been testing rewrite rules.
I want to unset them in bulk using something like:
git config --global --unset-all url.https://.insteadof
The git documentation says I can use a regex to match multiple values but I am struggling to format the command.
How to format the above command to match multiple urls and unset them all? Using wildcard syntax I would write something lile url.https://*
git config --unset-all
doesn't accept wildcards or regexps. So the task must be split into a few commands: 1st, get full keys that correspond to a regex; 2nd, unset the keys.
To get the keys and verify these are exactly the keys you want to unset use the command:
git config --global --get-regexp '^url\.https://.+\.insteadof'
To unset all the keys:
git config --global --get-regexp --name-only '^url\.https://.+\.insteadof' |
xargs -n1 git config --global --unset-al
Now repeat
git config --global --get-regexp '^url\.https://.+\.insteadof'
to check the keys were unset.
PS. Backup your ~/.gitconfig
before experimenting.