Questions tagged [git-config]

This command allows get and set repository or global options.

You can query/set/replace/unset options with this command. The name is actually the section and the key separated by a dot, and the value will be escaped.

Multiple lines can be added to an option by using the --add option. If you want to update or unset an option which can occur on multiple lines, a POSIX regexp value_regex needs to be given. Only the existing values that match the regexp are updated or unset. If you want to handle the lines that do not match the regex, just prepend a single exclamation mark in front (see also [EXAMPLES]).

The type specifier can be either --int or --bool, to make git config ensure that the variable(s) are of the given type and convert the value to the canonical form (simple decimal number for int, a "true" or "false" string for bool), or --path, which does some path expansion (see --path below). If no type specifier is passed, no checks or transformations are performed on the value.

When reading, the values are read from the system, global and repository local configuration files by default, and options --system, --global, --local and --file can be used to tell the command to read from only that location (see [FILES]).

When writing, the new value is written to the repository local configuration file by default, and options --system, --global, --file can be used to tell the command to write to that location (you can say --local but that is the default).

This command will fail with non-zero status upon error. Some exit codes are:

  • The config file is invalid (ret=3),

  • Can not write to the config file (ret=4),

  • No section or name was provided (ret=2),

  • The section or key is invalid (ret=1),

  • You try to unset an option which does not exist (ret=5),

  • You try to unset/set an option for which multiple lines match (ret=5), or

  • You try to use an invalid regexp (ret=6).

On success, the command returns the exit code 0.

This command allows get and set repository or global options.

635 questions
150
votes
2 answers

"simple" vs "current" push.default in git for decentralized workflow

Functionally speaking, in a decentralized workflow, I don't see the difference between simple and current options for push.default config setting. current will push the current branch to an identically named branch on the specified remote. simple…
void.pointer
  • 24,859
  • 31
  • 132
  • 243
145
votes
8 answers

How to tell git to use the correct identity (name and email) for a given project?

I use my personal laptop for both work and personal projects and I would like to use my work email address for my commits at work (gitolite) and my personal email address for the rest (github). I read about the following solutions which are all…
Martin Jambon
  • 4,629
  • 2
  • 22
  • 28
121
votes
6 answers

How to make git diff --ignore-space-change the default

I could probably setup an alias, but it seems like I should be able to set this as an option in the config file, only I don't see anyway to do it. I only want the --ignore-space-change when I'm doing diff, not when I'm doing apply or anything else. …
boatcoder
  • 17,525
  • 18
  • 114
  • 178
115
votes
2 answers

GIT warning: too many files skipping inexact rename detection

I am aware that the default rename limit is 100 and we can increase this value using the config diff.renamelimit config What I am worried about is that, if this config is not setup, will there be a wrong merge or any missing code? I am trying to…
Senthil A Kumar
  • 10,306
  • 15
  • 44
  • 55
115
votes
1 answer

How to colorize git-status output?

I want to colorize git-status output so that: untracked files = magenta new files = green modified files = blue deleted files = red I am instead seeing staged files in green and unstaged files in blue: My .gitconfig is setup with the following…
Andy
  • 2,154
  • 3
  • 20
  • 16
105
votes
10 answers

Where do the settings in my Git configuration come from?

I've noticed that I have two listings for core.autocrlf when I run git config -l $ git config…
RyanW
  • 5,338
  • 4
  • 46
  • 58
81
votes
16 answers

Unable to auto-detect email address

I'm new to SmartGit. I can't commit through my repository, the message I'm receiving is: Unable to auto-detect email address (got 'Arreane@Arreane-PC.(none)') *** Please tell me who you are. Run git config --global user.email "you@example.com" …
78
votes
4 answers

Pass an argument to a Git alias command

Can I pass arguments to the alias of a Git command? I have some alias in Git config, like so: rb1 = rebase -i HEAD~1 rb2 = rebase -i HEAD~2 rb3 = rebase -i HEAD~3 rb4 = rebase -i HEAD~4 .... Is it possible to make an rb alias so that git rb
HaveF
  • 2,995
  • 2
  • 26
  • 36
71
votes
4 answers

git config: list all variables and their default values

Similar to the MySQL show variables command that shows all variables and not just the ones defined in my.ini, I would like to see a list of all config variables in git along with their default values, and not just those defined in my ~/.gitconfig.…
Harry
  • 3,684
  • 6
  • 39
  • 48
69
votes
7 answers

Different .gitconfig for a given subdirectory?

I use two different git emails, one for work and one for public projects. Initially I thought that I could create a separate .gitconfig with a different email in a folder where all my public repos are in, and that git would respect that, but alas it…
Suan
  • 34,563
  • 13
  • 47
  • 61
67
votes
2 answers

How to emulate git log --decorate's different colors per branch-type

In making my favorite git log view I've created this alias: graph = log --pretty=format:'%Cgreen%ad%Creset %C(yellow)%h%Creset%C(yellow)%d%Creset %s %C(cyan)[%an]%Creset %Cgreen(%ar)%Creset' --date=short --graph This creates an output like: What…
Lode
  • 2,160
  • 1
  • 20
  • 25
57
votes
3 answers

Best practices for cross platform git config?

Context A number of my application user configuration files are kept in a git repository for easy sharing across multiple machines and multiple platforms. Amongst these configuration files is .gitconfig which contains the following settings for…
Bas Bossink
  • 9,388
  • 4
  • 41
  • 53
56
votes
6 answers

What are the consequences of using receive.denyCurrentBranch in Git?

I have a Git repository. I have cloned the repository and can commit my local changes. When I push my changes to the server it works. As soon as I create a branch, I checkout the branch, commit my work and then checkout the master branch. I then…
user1646481
  • 1,267
  • 6
  • 21
  • 29
54
votes
4 answers

fatal: No existing author found with 'XXX'

I used git for the first time and I set my user name and user mail. The commands I used are below: git config --global user.email "bob@example.com" git config user.email "bob@example.com" git config --global user.name "bob" git config user.name…
user2362956
53
votes
4 answers

git:// through proxy

I'm behind a firewall that is blocking port 9418 (git) and am trying to install some tools that are explicitly doing a checkout of git://github.com/..., so I can't switch to https for the checkout. So I'm wondering if it's possible to redirect all…
user578895
1
2
3
42 43