Search code examples
gitgit-untracked

How do I remove unwanted, untrack directories from my git branch?


For some reason I have untracked folders in my git branch that have nothing to do with my current directory. They seem to be mostly parallel directories.

I have no clue why but I've tried to use git ls-files --others --exclude-standard >> .gitignore and git clean -d -f -f.
Not sure if it is something up with my repo or what.

The only files that should exist are index.html and scripts.js

git status


Solution

  • Make sure you don't have a .git folder in the parent directory of the one including script.js.

    If you do (and don't care about its history), remove it, then initialize a git repo in your current folder (where script.js is)

    git init .
    git status
    

    Then you should see only your files, and not parent folders.