简体   繁体   中英

How to set git config values at runtime?

Is there a way to pass git config options to commands at runtime?

Example use case:

The git commit command does not have a -U option (ie. git diff ) to change context lines of -v verbose output, and the user does not want to set diff.context in config files.

man git :

-c <name>=<value>

Pass a configuration parameter to the command. The value given will override values from configuration files. The is expected in the same format as listed by git config (subkeys separated by dots).

Note that omitting the = in git -c foo.bar... is allowed and sets foo.bar to the boolean true value (just like [foo]bar would in a config file). Including the equals but with an empty value (like git -c foo.bar=... ) sets foo.bar to the empty string which git config --type=bool will convert to false.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM