-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Setup
- Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options
git version 2.15.1.windows.2
built from commit: 5d5baf91824ec7750b103c8b7c4827ffac202feb
sizeof-long: 4
machine: x86_64
- Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver
Microsoft Windows [Version 10.0.16299.98]
- What options did you set as part of the installation? Or did you choose the
defaults?
> type "c:\Program Files\Git\etc\install-options.txt"
Editor Option: VIM
Path Option: Cmd
SSH Option: OpenSSH
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Performance Tweaks FSCache: Enabled
Use Credential Manager: Enabled
Enable Symlinks: Disabled
However, I have also tried manually changing the symlink setting:
> type c:\ProgramData\Git\config
[core]
symlinks = true
autocrlf = true
fscache = true
(...)
> git config --global --get core.symlinks
true
Details
- Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other
This repros from both CMD and Cygwin ZSH
- What commands did you run to trigger this issue? If you can provide a
Minimal, Complete, and Verifiable example
this will help us understand the issue.
I try to keep all my configuration files in OneDrive, and use symlinks to point to them. I have both ~/.gitconfig and ~/.gitignore in OneDrive. Cygwin and WSL git are both happy with this arrangement, but Git for Windows ignores and refuses to use a symlinked .gitignore file (even if it's still happy with a symlink at ~/.gitconfig).
Here's a self-contained repro, starting from C:\Users\<me>:
> echo "somepattern" > .gitignore
> git config --global core.excludesfile ~/.gitignore
> type .gitconfig
[core]
excludesfile = ~/.gitignore
> mkdir tmp
> cd tmp
> git init
Initialized empty Git repository in c:/Users/<me>/tmp/.git/
> git status
On branch master
No commits yet
nothing to commit (create/copy files and use "git add" to track)
> cd ..
> mv .gitignore thegitignore
> mklink .gitignore thegitignore
symbolic link created for .gitignore <<===>> thegitignore
> cd tmp
> git status
fatal: cannot use C:/Users/<me>/.gitignore as an exclude file
- What did you expect to occur after running these commands?
Git reads and uses my custom .gitignore file, just as it did in the first instance of "git status" when it wasn't a symlink.
- What actually happened instead?
Git prints the warning:
fatal: cannot use C:/Users/<me>/.gitignore as an exclude file
and ignores the contents of that file.
A syscall trace shows that git is actually following the symlink and reading the contents of the linked file before ignoring it, so it's unclear what exactly is wrong with having a symlink there:
