Git config

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.



Tutorials dojo strip

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

OptionDescription
--replace-allReplace all lines matching the key (and optionally the value pattern) rather than just one.
--appendAdd a new line to the option without altering existing values.
--comment <message>Append a comment to new or modified lines.
--allWith get, return all values for a multi-valued key.
--regexpWith get, interpret the name as a regular expression.
--url=<URL>Return the value for the key with the best matching URL.
--globalWrite to or read from the global ~/.gitconfig file.
--systemWrite to or read from the system-wide $(prefix)/etc/gitconfig file.
--localWrite to or read from the repository’s .git/config file (default behavior).
--worktreeSimilar 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-valueTreat 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-typeUnset the previously set type specifier.
-z, --nullEnd values with the null character instead of a newline.
--name-onlyOutput only the names of config variables.
--show-originAugment the output with the origin type and actual origin of each queried config option.
--show-scopeAugment 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-]includesRespect 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"
Scroll to Top