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?
Asked
Active
Viewed 209 times
-2

gkeenley
- 6,088
- 8
- 54
- 129
-
1Just add them back: `git add` – dapetillo Nov 07 '22 at 16:18
-
This worked, thanks! Feel free to post as a reply so I can approve. – gkeenley Nov 07 '22 at 16:42
-
No problem. I also added some more detail in the answer. – dapetillo Nov 07 '22 at 18:46
-
1Helps to know what tracked / untracked _means_. Basically it means is / isn't in the Index. – matt Nov 07 '22 at 18:55
1 Answers
1
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
).

dapetillo
- 161
- 3