The git config
command lets you change settings in Git. You can set things like your name, email, and which text editor you want to use with Git. These settings can be applied for all your projects, just one project, or for all users on your computer.
Initial Example
To set your name for all your Git projects, use:
git config --global user.name "Your Name"
Levels of Settings
- System (
--system
): Applies to all users on your computer. - Global (
--global
): Applies to all your Git projects. - Local (
--local
): Applies only to the project you’re working on.
CONFIG Options
Option | Description |
---|---|
--replace-all | Replace all lines matching the key (and optionally the value pattern) rather than just one. |
--append | Add a new line to the option without altering existing values. |
--comment <message> | Append a comment to new or modified lines. |
--all | With get , return all values for a multi-valued key. |
--regexp | With get , interpret the name as a regular expression. |
--url=<URL> | Return the value for the key with the best matching URL. |
--global | Write to or read from the global ~/.gitconfig file. |
--system | Write to or read from the system-wide $(prefix)/etc/gitconfig file. |
--local | Write to or read from the repository’s .git/config file (default behavior). |
--worktree | Similar to --local , but reads from or writes to $GIT_DIR/config.worktree if extensions.worktreeConfig is enabled. |
-f, --file <config-file> | Write to or read from the specified file. |
--blob <blob> | Use the given blob instead of a file, e.g., master:.gitmodules . |
--fixed-value | Treat the value pattern as an exact string instead of a regular expression. |
--type <type> | Ensure the input or output is valid under the given type constraint (e.g., bool , int , path ). |
--no-type | Unset the previously set type specifier. |
-z, --null | End values with the null character instead of a newline. |
--name-only | Output only the names of config variables. |
--show-origin | Augment the output with the origin type and actual origin of each queried config option. |
--show-scope | Augment the output with the scope of each queried config option. |
--get-colorbool <name> [<stdout-is-tty>] | Find the color setting for <name> and output “true” or “false” based on the provided or standard output’s TTY status. |
--[no-]includes | Respect or ignore include.* directives in config files. Defaults to off with specific files. |
--default <value> | Use the specified default value if the requested variable is not found. |
Examples
1. Set Your Email
To set your email address for all your Git projects:
git config --global user.email "your.email@example.com"
2. Choose Your Text Editor
To set Vim as your default text editor for Git:
git config --global core.editor "vim"
3. Set a Merge Tool
To choose Meld as your merge tool for resolving conflicts:
git config --global merge.tool "meld"
4. See All Settings
To list all your Git settings:
git config --list
5. Project-Specific Settings
To set a different name for a specific project, go to that project’s directory and use:
git config user.name "Project Specific Name"