I have git 2.6.2 installed in Windows 7.
I have core.autocrlf set to False. I'd like to know where that setting comes from. I have the following weird behavior:
> cd c:\
> git config --global --list | select-string autocrlf
> git config --system --list | select-string autocrlf
fatal: unable to read config file 'C:\Program Files\Git\mingw64/etc/gitconfig': No such file or directory
> git config --list | select-string autocrlf
core.autocrlf=false
core.autocrlf=False
> git config core.autocrlf
False
So I have not set core.autocrlf in the global config. I have no system config. I am currently not in a git directory. Still, I get no less than two core.autocrlf settings.
Are they generated by the Git binary? (if so, why two settings?)
Look in C:\ProgramData\Git\config.
And see this question for more details (it's not just core.autocrlf that has a "phantom" value, there's more :) )
Related
I clone the repo, open it on IDE on Windows, and it shows to me, that I modified all the files. When I add them and push, it shows me in the pull request, that I have changed them from the beginning to the end, even though the content is the same and I didn't make any changes. Is there any way to solve the problem?
The .gitattributes file is the following:
*.js text eol=crlf
*.jsx text eol=crlf
bin/* eol=lf
My git configs on the computer are the following:
[user]
name = ****
email = ***
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[core]
autocrlf = input
What I have tried:
I have tried the following commands (a piece of advice from Krzysztof):
git rm --cached -r .
git reset --hard
Set git config to core.autocrlf input (a piece of advice from a programmer-friend of a colleague)
git config --global core.autocrlf input
Delete the repo and clone it again several times
I want to configure Git, but I deleted my configuration file before (a big mistake). It shows me
No such file or directory
when I put in ~/.gitconfig:
$ git config global user.name "a"
error: key does not contain a section: global
$ ~/.gitconfig
-bash:/.gitconfig: No such file or directory
Add dashes to global:
git config --global user.name "a"
Without the dashes global is getting interpreted as a section, but that's not valid. You want the --global flag.
The file doesn't need to exist before you run this command. Git will create it if it's not there.
I tried to remove the values (to reset them) but they won't go away. Plus they contradict each other.
C:\Users\Chloe\workspace\app>git config --unset-all core.autocrlf
C:\Users\Chloe\workspace\app>git config --unset-all core.editor
C:\Users\Chloe\workspace\app>git config --unset-all core.edit
C:\Users\Chloe\workspace\app>git config -l | grep autocrlf
core.autocrlf=true
core.autocrlf=false
C:\Users\Chloe\workspace\app>git config -l | grep notepad
core.editor=/C/Program Files/Notepad++/notepad++.exe
core.edit=C:\\Program Files\\Notepad++\\notepad++.exe
I tried to edit the values with git config -e (but first I had to figure out how to specify the path correctly), and it didn't list either of those config keys.
git version 2.16.3.windows.1
I found this answer http://stackoverflow.com/questions/2114111/ddg#2115116
And I used git config --list --show-origin then edited the files manually (from an elevated Notepad++). I had
file:"C:\\ProgramData/Git/config" core.autocrlf=true
file:C:/Users/Chloe/.gitconfig core.autocrlf=false
file:C:/Users/Chloe/.gitconfig core.editor=/C/Program Files/Notepad++/notepad++.exe
file:C:/Users/Chloe/.gitconfig core.edit=C:\\Program Files\\Notepad++\\notepad++.exe
Overall it was looking in 4 places: C:\ProgramData\Git\config, C:\Program Files\Git\mingw64\etc\gitconfig, C:/Users/Chloe/.gitconfig, .git/config.
Run git config -l --show-origin to see where from the settings come. Most probably from the global ~/.gitconfig so remove them with
git config --global --unset-all core.autocrlf
I've read the Git documentation and Where do the settings in my Git configuration come from? and yet I still can't make sense of some of my settings.
I'm on Git 2.5.3 on Windows 10. Here's the output of git config -l:
λ git config -l
core.symlinks=false
core.autocrlf=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
pack.packsizelimit=2g
help.format=html
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
sendemail.smtpserver=/bin/msmtp.exe
diff.astextplain.textconv=astextplain
rebase.autosquash=true
user.name=Ben Collins
user.email=#redacted#
alias.sm=submodule
alias.br=branch
alias.co=checkout
alias.st=status
alias.rebuild=!git rm --cached -r . && git reset --hard
core.excludesfile=C:\Users\Benjamin\Documents\gitignore_global.txt
core.editor=c:/Users/Benjamin/AppData/Local/atom/bin/atom.cmd
core.attributesfile=C:\Users\Benjamin\.gitattributes
push.default=simple
merge.tool=p4merge
mergetool.p4merge.cmd=p4merge.exe "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
mergetool.p4merge.path=C:/Program Files/Perforce/p4merge.exe
gui.encoding=utf-8
diff.guitool=p4merge
difftool.p4merge.path=C:/Program Files/Perforce/p4merge.exe
difftool.p4merge.cmd=p4merge.exe "$LOCAL" "$REMOTE"
mergetool.keepbackup=false
rerere.enabled=true
credential.helper=!'C:\Users\Benjamin\AppData\Roaming\GitCredStore\git-credential-winstore.exe'
filter.lfs.clean=git lfs clean %f
filter.lfs.smudge=git lfs smudge %f
filter.lfs.required=true
color.diff.whitespace=red reverse
What's bothersome is that the first twelve settings I cannot find anywhere.
C:\Program Files\Git
λ git config --system --list
fatal: unable to read config file 'C:\Program Files\Git\mingw64/etc/gitconfig': No such file or directory
C:\Program Files\Git
λ git config --global --list
user.name=Ben Collins
user.email=#redacted#
alias.sm=submodule
alias.br=branch
alias.co=checkout
alias.st=status
alias.rebuild=!git rm --cached -r . && git reset --hard
core.excludesfile=C:\Users\Benjamin\Documents\gitignore_global.txt
core.editor=c:/Users/Benjamin/AppData/Local/atom/bin/atom.cmd
core.attributesfile=C:\Users\Benjamin\.gitattributes
push.default=simple
merge.tool=p4merge
mergetool.p4merge.cmd=p4merge.exe "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
mergetool.p4merge.path=C:/Program Files/Perforce/p4merge.exe
gui.encoding=utf-8
diff.guitool=p4merge
difftool.p4merge.path=C:/Program Files/Perforce/p4merge.exe
difftool.p4merge.cmd=p4merge.exe "$LOCAL" "$REMOTE"
mergetool.keepbackup=false
rerere.enabled=true
credential.helper=!'C:\Users\Benjamin\AppData\Roaming\GitCredStore\git-credential-winstore.exe'
filter.lfs.clean=git lfs clean %f
filter.lfs.smudge=git lfs smudge %f
filter.lfs.required=true
color.diff.whitespace=red reverse
Also, when I try to unset one of the first twelve settings, it has no effect:
C:\Users\Benjamin\Projects\blah [master +0 ~1 -0]
λ git config --unset core.autocrlf
C:\Users\Benjamin\Projects\blah [master +0 ~1 -0]
λ git config core.autocrlf
true
C:\Users\Benjamin\Projects\Saddleback\cm-core [master +0 ~1 -0]
λ git config --unset-all core.autocrlf
C:\Users\Benjamin\Projects\Saddleback\cm-core [master +0 ~1 -0]
λ git config core.autocrlf
true
Are these first twelve settings hardcoded or platform-specific somehow? How do I get control of them?
As this commit explains, they've added another config location only for Windows, which is applied even before the --system:
The file /etc/gitconfig can be used to store a system-wide default
configuration. On Windows, configuration can also be stored in
C:\ProgramData\Git\config; This file will be used also by
libgit2-based software.
...
On Windows, as there is no central /etc/ directory, there is yet
another config file, intended to contain settings for all
Git-related software running on the machine. Consequently, this config
file takes an even lower precedence than the $(prefix)/etc/gitconfig
file.
So I believe you can find those mystery settings in C:\ProgramData\Git\config.
From that commit I can see that git config --system --list should've shown you those settings, but it seems that the absence of C:\Program Files\Git\mingw64/etc/gitconfig file aborted the operation, which is probably a bug.
In my version of git there is a --show-origin switch on the list command which gives away where the setting was applied from. I agree that it's confusing that there is no provided switch to access the windows configuration location inside ProgramData.
C:\Users\karlb>git --version
git version 2.11.0.windows.3
C:\Users\karlb>git config --list --show-origin
file:"C:\\ProgramData/Git/config" core.symlinks=false
file:"C:\\ProgramData/Git/config" core.autocrlf=true
file:"C:\\ProgramData/Git/config" core.fscache=true
file:"C:\\ProgramData/Git/config" color.diff=auto
file:"C:\\ProgramData/Git/config" color.status=auto
file:"C:\\ProgramData/Git/config" color.branch=auto
file:"C:\\ProgramData/Git/config" color.interactive=true
file:"C:\\ProgramData/Git/config" help.format=html
file:"C:\\ProgramData/Git/config" http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
file:"C:\\ProgramData/Git/config" diff.astextplain.textconv=astextplain
file:"C:\\ProgramData/Git/config" rebase.autosquash=true
file:"C:\\Program Files\\Git\\mingw64/etc/gitconfig" credential.helper=manager
file:"C:\\Program Files\\Git\\mingw64/etc/gitconfig" difftool.usebuiltin=true
file:"C:\\Program Files\\Git\\mingw64/etc/gitconfig" alias.lol=log --oneline --graph
file:"C:\\Program Files\\Git\\mingw64/etc/gitconfig" alias.last=log -1 HEAD
file:C:/Users/karlb/.gitconfig user.email=karl.horton#yahoo.com
file:C:/Users/karlb/.gitconfig user.name=Karl Horton
TIL a caveat concerning Git for Widows. I have git version 2.17.1.windows.2.
I tried to set a global core.attributesfile to override the line-ending attributes for *.sh files (I use WSL, and the present version becomes very unhappy when it tries to run shell scripts with DOS (CRLF) line endings. For Git on the Linux side, the following lines in ~\.gitattributes solve the problem:
*.sln text eol=crlf
*.bat text eol=crlf
*.sh text eol=cr
But using Git from Windows side (e.g. via Sourcetree GUI), for some repositories, I was still getting CRLF in *.sh files.
I found that in these repositories, core.autocrlf=true. Setting it to input solves the problem, and Git respects the global gitattributes now.
git, windows 7. I try set a text editor via different ways:
$ git config --global core.editor "C:\Program Files\Notepad++\notepad++.exe"
$ git config --global core.editor \"C:\Program Files\Notepad++\notepad++.exe\"
$ git config --global core.editor 'C:\Program Files\Notepad++\notepad++.exe'
But when I look the config file (via the git config --list command), I get the same result:
core.editor=C:\Program Files\Notepad++\notepad++.exe
So, I can't do a commit, I get an error:
$ git commit C:\Program Files\Notepad++\notepad++.exe: C:Program:
command not found error: There was a problem with the editor
'C:\Program Files\Notepad++\notepad++ .exe'. Please supply the message
using either -m or -F option.
I tried edit the .gitconfig file manually (I added the quotes) but it is not help me.
Why quotes are ignored and how can I solve it?
Try that
git config --global core.editor "'C:\Program Files\Notepad++\notepad++.exe'"
You should use forward slashes (/) rather than backslashes (\) in your pathname.
Source: [here] under "Configuring git and the helpers"