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.

534 questions
1955
votes
24 answers

Is there a way to cache GitHub credentials for pushing commits?

I recently switched to synchronizing my repositories to https:// on GitHub (due to firewall issues), and it asks for a password every time. Is there a way to cache the credentials, instead of authenticating every time that git push?
Zepplock
  • 27,080
  • 4
  • 33
  • 49
1732
votes
21 answers

How to save username and password in Git?

I want to use a push and pull automatically in GitExtension, without entering my user and password in a prompt, every time. So how can I save my credentials in git?
Edson Cezar
  • 17,674
  • 4
  • 14
  • 25
1580
votes
16 answers

How do I commit case-sensitive only filename changes in Git?

I have changed a few files name by de-capitalize the first letter, as in Name.jpg to name.jpg. Git does not recognize this changes and I had to delete the files and upload them again. Is there a way that Git can be case-sensitive when checking for…
Gil Shulman
  • 15,819
  • 3
  • 10
  • 4
870
votes
21 answers

Can I specify multiple users for myself in .gitconfig?

In my ~/.gitconfig, I list my personal email address under [user], since that's what I want to use for Github repos. But, I've recently started using git for work, too. My company's git repo allows me to commit, but when it sends out announcements…
Brock Boland
  • 13,320
  • 10
  • 31
  • 36
408
votes
12 answers

Is it possible to have different Git configuration for different projects?

.gitconfig is usually stored in the user.home directory. I use a different identity to work on projects for Company A and something else for Company B (primarily the name / email). How can I have two different Git configurations so that my check-ins…
priya
  • 19,365
  • 24
  • 59
  • 76
292
votes
12 answers

git: 'credential-cache' is not a git command

I followed these instructions to the letter, including the part about password caching. It seems like the instructions are wrong, because every time I git push origin master I get this error: git: 'credential-cache' is not a git command. See 'get…
Big McLargeHuge
  • 11,456
  • 8
  • 64
  • 92
270
votes
3 answers

Difference between author and committer in Git?

I am trying to make a commit like git commit --author="John Doe " -m "" where John Doe is some user in whose name I want to make the commit. It appears all right in git log. However, when I do a gitk, the…
Anshul Goyal
  • 61,070
  • 31
  • 133
  • 163
254
votes
14 answers

How to change my Git username in terminal?

I was pushing and pulling from git in Terminal then I changed my username on github.com. I went to push some changes and it couldn't push because it was still recognizing my old username.. How do I change/update my username on git in terminal?
user3370902
  • 2,633
  • 2
  • 12
  • 12
224
votes
16 answers

How can I make Sublime Text the default editor for Git?

I have a problem setting Sublime Text 2 as the core.editor with git. I've read through every post I could find addressing the problem, but still nothing is working for me. I am running Windows. I have done: git config --global core.editor…
Spencer Moran
  • 2,320
  • 3
  • 13
  • 13
219
votes
8 answers

How to know the git username and email saved during configuration?

While configuring git I ran these two commands: git config --global user.name "My Name" git config --global user.email "myemail@example.com" However, I doubt whether I made a typo or not. So, is there any command to know the name and email which…
Jebin Philipose
  • 2,933
  • 2
  • 7
  • 14
174
votes
6 answers

With Git, how do I turn off the "LF will be replaced by CRLF" warning

With Git, when using the autocrlf = true flag, a warning is still given when line-endings are changed. I understand what the warning is for, and how to turn off the line-ending flag, but how do I turn off the warning itself?
sent-hil
  • 16,955
  • 15
  • 53
  • 71
152
votes
2 answers

git multiple user names for the different projects within the same system

I have a different git repository for my office and a different git repo for my hobby projects. When I do git config --global user.name the user name changes globally and this creates a confusion of committing to a repo with user name. Hence the…
whatf
  • 5,847
  • 12
  • 44
  • 77
133
votes
9 answers

Git: can I suppress listing of 'modified content'/dirty submodule entries in status, diff, etc?

Somewhen (around the 1.6.x releases, I think) git became aware of changes inside submodules. That only serves to annoy me: $ git status vendor | grep modified: # modified: vendor/rails (modified content) $ git diff vendor/ diff --git…
kch
  • 71,135
  • 44
  • 128
  • 148
129
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
  • 21,280
  • 21
  • 106
  • 196
123
votes
14 answers

git: fatal unable to auto-detect email address

I just cannot commit with git on Ubuntu 14.04 Error message is: git: fatal unable to auto-detect email address (got "some wrong email") I tried git-config with and without the --global option setting user.name and user.mail but nothing works
user2428094
  • 1,343
  • 2
  • 8
  • 6
1
2 3
35 36