Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git clean -fdx deletes tracked files #1270

Closed
kimbirkelund opened this issue Aug 17, 2017 · 12 comments
Closed

git clean -fdx deletes tracked files #1270

kimbirkelund opened this issue Aug 17, 2017 · 12 comments
Labels

Comments

@kimbirkelund
Copy link

Hi

I hope this is gonna sound as weird to you as it does to me.

The link below is a zip of a small git repository that I can reproduce
the bug in on 4 machines. The machines were a mix of Win10, WinServer2012R2 and WinServer2016 (all fully updated).

Repo: https://www.dropbox.com/s/fz4d0i5ko7s7ktr/test.zip?dl=0

It contains 2 folders: helpers and b, each of which is an empty npm
module. b\package.json refers to the helpers module.

The following reproduces the bug:

  1. in terminal cd to the b folder
  2. run npm install
  3. run git reset HEAD --hard
  4. run git clean -fdx

At this point both files in the helpers folder has been deleted and
running git status confirms this.

Tool version:

git --version => git version 2.10.2.windows.1 and git version 2.14.1.windows.1
node -v => v6.11.2
npm -v => 5.3.0

I have no idea what is going. Very much hope you can explain :-)

@dscho
Copy link
Member

dscho commented Aug 22, 2017

Somebody on the mailing list suggested this may be a bug related to junction points. Can you confirm?

@dscho dscho added the unclear label Aug 22, 2017
@kimbirkelund
Copy link
Author

kimbirkelund commented Aug 22, 2017 via email

@dscho
Copy link
Member

dscho commented Aug 22, 2017

I don't see how. Unless npm messes with junction points internally.

Since you have a setup where you can easily see the issue, it would be a pretty helpful thing to find out on your side if npm messes with junction points internally.

@kimbirkelund
Copy link
Author

It apparently does mess with either junctions or symlinks.

When npm install is run in the b module, a link is made at b\node_modules@sekoia\helpers to helpers.

When git clean is run it presumable deletes the inner most untracked files instead of the outer most untracked folder.

@vidartf
Copy link

vidartf commented Nov 7, 2017

Node's fs package (filesystem API used by npm) creates junctions on Windows. Note that this issue is potentially more severe than just deleting files in the repo:

REM Setup some directories for testing:
mkdir test-junctions-del
echo "content" > test-junctions-del\file.txt
dir test-junctions-del
mkdir my-git-repo
cd my-git-repo
git init

REM Create junction link:
mklink /J mylink ..\test-junctions-del

REM Blow it up:
git clean -xdf
dir ..\test-junctions-del

Or, if you are brave, point the junction to 'C:\'... (please don't).

@vidartf
Copy link

vidartf commented Nov 7, 2017

Seems to be a duplicate of #607.

@vidartf
Copy link

vidartf commented Nov 7, 2017

Here is the line in npm that creates a link, specifying the junction type for Windows.

@vidartf
Copy link

vidartf commented Nov 7, 2017

I have also opened a corresponding issue on the npm repo: npm/npm#19091

@dscho
Copy link
Member

dscho commented Jan 3, 2018

I think this ticket may actually be a duplicate of #607, and we may soon have a fix via #1414.

@dscho
Copy link
Member

dscho commented Oct 13, 2019

I think this ticket may actually be a duplicate of #607, and we may soon have a fix via #1414.

Even if I have heard nothing to confirm this (it would have been nice, or at least a validation of my work, if I saw people at least test the stuff I produce, even better would be to help actively, of course), I will just assume that this was indeed fixed, even without confirmation, and close this ticket.

@dscho dscho closed this as completed Oct 13, 2019
@vidartf
Copy link

vidartf commented Oct 14, 2019

@dscho I did install it since the pre-release and it has been working as intended. I meant to report back, but since it worked smoothly, it faded from memory. Thanks again!

@vidartf
Copy link

vidartf commented Oct 14, 2019

(For reference for others, the PR containing the fixes ended up being #2268)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants