Daniel Stephens
Daniel Stephens

Reputation: 3209

Why does git clean and reset leave files behind?

I use git clean -xdf with git reset --hard to completely reset my branch and discard all changes. But after both calls, some files are left in the directory. No process is locking these files (verified with Process Explorer)

$ git reset --hard
$ git clean -xdf
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        ../application.pdb

What could be the issue? Any help is appreciated!

Upvotes: 0

Views: 103

Answers (2)

torek
torek

Reputation: 487755

Note the name of the untracked file:

    ../application.pdb

Note in particular that this name starts with ...

The git clean command works from the current directory:

$ touch foo
$ git clean -n
Would remove foo
$ cd Documentation
$ git clean -n
$ git clean -f
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        ../foo

nothing added to commit but untracked files present (use "git add" to track)
$ cd ..
$ git clean -f
Removing foo
$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

When you installed an updated Git (not a bad idea anyway), you no doubt went back to the top level of the repository.

Upvotes: 3

Daniel Stephens
Daniel Stephens

Reputation: 3209

Git was outdated from 2.25.0. I updated to the latest 2.26.2 and it worked

Upvotes: 0

Related Questions