Git: how to reset untracked files?

482 views Asked by At

I made a commit, then changed some files in my project, then did git reset --hard HEAD. It said untracked files for all the files I had added. How do I resolve this so that those files are tracked and get reset along with the rest of the project?

1

There are 1 answers

0
dapetillo On

Some more details on my comment:

The command performed by gkeenley with the --hard option tells git to not only reset HEAD, that is, their last commit but also the index (where git "caches" changes to files and trees) as well as the working tree. Thus git add will simply stage the changes of the commit before the reset.

An alternative could have been using the git reset --soft. This would leave index and working tree untouched and only reset HEAD, leaving the changes of the last commit ready to be committed again (basically avoiding using git add before git commit).