gitwindows-7cygwin

Why does Git have different config in Cygwin from Windows 7 Terminal?


I was under the impression that all Git config goes in some text file under the .git directory. That doesn't seem to be the case because I added a core.editor config parameter in Cygwin to tell Git in Cygwin what text editor to use when amending or squashing:

git config --global core.editor "D:/homex/SFTWR/cygwin/bin/vi.exe"

I thought that was going to also take effect when using Git in the regular Windows 7 Terminal (the DOS-like CLI), which was OK because that vi executable actually works in Windows outside Cygwin.

But when I ran

git config --list

in Terminal, the core.editor variable did not appear. All the other ones did. So the config list in Cygwin shows 30 variables and in the Terminal 29. I figure that if the config were saved in some text file within the project's .git directory, it should be the same for every interface through which it is accessed.

My Git editor works in both interfaces, that is not a problem. I am just curious how this thing works under the hood and why Cygwin and Terminal show different configurations.


Solution

  • It could be that Cygwin/Windows are using two separate global .gitconfig files.

    You can confirm which configuration file is being used by running the following in both Cygwin and Windows Command Prompt and checking which files are opened.

    git config --global --edit
    

    To fix this, you can delete the .gitconfig copy in your Cygwin home directory and replace it with a hard link to the .gitconfig copy in your Windows home directory. First delete the file, then open cmd with administrator privileges and run:

    mklink /H "C:\cygwin64\home\youruser\.gitconfig" "C:\Users\youruser\.gitconfig"

    More details about hard links are available here: https://www.howtogeek.com/howto/16226/complete-guide-to-symbolic-links-symlinks-on-windows-or-linux/