Git: Deleting stubborn untracked files

Posted on

Alright I’ve ran into this problem way too many times and not kept a note on this so to save myself the trouble (and to the poor donkeys out there who are on the same boat) I’m making a note now so I won’t forget … and to help everybody out there.

Lets say you’ve finished on your assignment and you hit git status before pushing your work into your remote repository. You get something like this:

Benji$  git status
On branch feature/LOLMACHINE
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	deleted:    Animations/nyancat.meta
	modified:   LOL_Game.unity

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

	../ProjectSettings/stubbornfile.asset
	../ProjectSettings/stubbornfile2.asset
	../ProjectSettings/stubbornfile3.asset

Try as you might Git reset HEAD and Git reset doesn’t work.

Luckily you can get rid of untracked files using the simple git clean -xf

If you feel compelled to remove everything including the directories you worked on but might not necessarily be needed then you can use git clean -df and BOOM, all is good again.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s