user2924482
user2924482

Reputation: 9120

GIT: After git reset --hard HEAD still shows uncommitted changes

I git reset hard my local directory:

git reset --hard HEAD

But still shows this:

git status
On branch step4
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    ./

nothing added to commit but untracked files present (use "git add" to track)

Any of you knows how can fix this?

I'll really appreciate your help.

Upvotes: 2

Views: 2725

Answers (3)

Jake Dube
Jake Dube

Reputation: 2990

As the other answers say, the file is not currently tracked. To only remove them from the status display, but not from disk, add the file to your .gitignore, e.g.:

echo "file.txt" >> .gitignore

Upvotes: 0

Norman Percy
Norman Percy

Reputation: 1158

After you git reset --hard, you need to run git clean in order to remove untracked files. These files are deleted from the drive. If you want to reset your directory completely, run git clean -dfx. If you want to be more selective, try running git clean -dfxi or messing with the parameters as you see fit.

Upvotes: 1

Do not use git reset to remove untracked files. This is what git clean is for.

git reset will only reset the HEAD pointer to the commit you specified. The option --soft will keep all tracked files as they are while --hard reverts them to the state of the commit.

You can clean your working directory with git clean -f.

Upvotes: 1

Related Questions