Bad combination: git for Windows + npm.link's use of junctions

cli
priority:low
triaged

(Zebra Flesh) #1

Copied from https://github.com/npm/npm/issues/19091 because this issue is terrible and needs to be fixed.

What’s going wrong?

If using npm link package-name on Windows, a junction will be created. If this is inside a git repository (with git set to ignore node_modules), performing git clean -xdf inside the repository (with a git for Windows installation), git will recurse into the junction and delete all content. See the relevant issues on the git for Windows repository: git-for-windows/git#607 git-for-windows/git#1270.

Steps to reproduce

  • Install git for Windows.
  • Link a package into an install in a repository ( npm init + npm link package-name in repository).
  • Run git clean -xdf in repository.
  • The files in the package-name install are now gone.

Supporting information:

With recent versions of Windows 10, user of machine with Developer Mode enabled can create symlinks without elevated privileges. It would be nice if there was a flag or config option to configure what kind of link to create, as has been suggested before: #8520

Note: Git for Windows have previously concluded that junctions should be treated as hardlinks, not symlinks, and therefore that it is correct to recurse into the folder for cleaning. Npm seem to disagree.

Platform Info

git --version
git version 2.19.1.windows.1
node --version
v10.8.0
npm --version
6.4.1
ver
Microsoft Windows [Version 10.0.17134.320]