git-var - Linux


git-var is a powerful tool within the Git environment that allows users to set, retrieve, and modify configuration variables and custom properties. This command provides fine-grained control over various aspects of Git’s behavior and customization, enabling you to tailor your workflow to your specific needs.


git var [<command>] [<pattern>] [<value>]


| Flag | Description | Default Value |
| -l or --list | Lists all available configuration variables | N/A |
| -g or --global | Modifies the global configuration | N/A |
| -s or --system | Modifies the system-wide configuration | N/A |
| -x or --unset | Unsets the specified variable | N/A |


1. Set a custom variable:

git var FOO bar

2. Retrieve a variable value:

git var FOO

3. Modify a variable:

git var FOO bar --global

4. List all variables:

git var -l

Common Issues

  • Variable not set: Ensure you use the correct scope (global, system, or local). Use the -g, -s, or no flags accordingly.
  • Variable overridden: Custom variables can be overridden by higher scope variables. Check the global and system configurations if the local variable is not working as expected.


git-var can be integrated with other Git commands as follows:

  • .gitconfig file: Variables set with git-var can be stored persistently in the .gitconfig file.
  • Bash scripts: You can use the command in Bash scripts to automate variable management tasks.
  • Custom Git aliases: Create aliases to quickly set or retrieve variables using git config --global alias.alias 'git var <command> <variable>'.

Related Commands

  • git config: Manages Git configuration settings.
  • git help: Provides documentation on all available Git commands.
  • man git-config: Displays the official manual page for git-config.