How to get rid of links to unwanted files using Git

I accidentally pinned the template project inside the project working tree with the Git repository (I was inside the project folder, created the folder, entered it and typed yo gulp-webapp).

It happens, right?

So, first I returned the overwritten files with git checkout HEAD -- <filename>.

After that, typing git status, some unwanted files were displayed in the "Tracked Files".

I deleted them (via Sublime Text), and then they appeared in "Changes not set for commit." What for? Were they not tracked, that is, they were never added to the repository?

Then I deleted them using git -rm -rf. Now they appear in the staging area. What's happening.

How to make git forget about them?

+4
source share
2 answers
git clean -xdf

This will remove unnecessary files, directories (-d) and files ignored with .gitignore (-x).

Be careful not to delete files accidentally, this will clear everything that is not tracked.

You can add a parameter --dry-runto see what will be deleted.

+4
source

After you have done git rm, the files appeared in the staging area because they must be deleted in the repository, i.e. right that they are. Just do the removal and you should be good to go.

0
source

All Articles