gitgit-clean

How can i remove untracked changes and deleted files showing on my git terminal


I have been trying to get rid of the untracked files showing up when I run git status on my Git Bash terminal. This has also affected my whole computer system as I usually see different files as well as files added to the ones I intend to push to my Github repository.

  modified:   ../../FrontEndMentorsChallenges/intro-component-with-signup-form-master/index.html
        modified:   ../../FrontEndMentorsChallenges/intro-component-with-signup-form-master/script.js
        modified:   ../../FrontEndMentorsChallenges/intro-component-with-signup-form-master/style.css
        modified:   ../../FrontEndMentorsChallenges/intro-component-with-signup-form-master/style1.css
        deleted:    ../../intro-component-with-signup-form-master/.gitignore
        deleted:    ../../intro-component-with-signup-form-master/README.md
        deleted:    ../../intro-component-with-signup-form-master/design/active-states.jpg
        deleted:    ../../intro-component-with-signup-form-master/design/desktop-design.jpg
        deleted:    ../../intro-component-with-signup-form-master/design/desktop-preview.jpg
        deleted:    ../../intro-component-with-signup-form-master/design/mobile-design.jpg
        deleted:    ../../intro-component-with-signup-form-master/images/bg-intro-desktop.png
        deleted:    ../../intro-component-with-signup-form-master/images/bg-intro-mobile.png
        deleted:    ../../intro-component-with-signup-form-master/images/favicon-32x32.png
        deleted:    ../../intro-component-with-signup-form-master/images/icon-error.svg
        deleted:    ../../intro-component-with-signup-form-master/index.html
        deleted:    ../../intro-component-with-signup-form-master/script.js
        deleted:    ../../intro-component-with-signup-form-master/style-guide.md
        deleted:    ../../intro-component-with-signup-form-master/style.css
        deleted:    ../../intro-component-with-signup-form-master/style1.css

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        ../
        ../../Access 2013.lnk
        ../../BradTraversery CodeAlong Projects/
        ../../Excel 2013.lnk
        ../../Fonts/
        ../../Fork.lnk
        ../../FrontEndMentorsChallenges/Travelix-master/    
        ../../FrontEndMentorsChallenges/coding-bootcamp-testimonials-slider-master/
        ../../FrontEndMentorsChallenges/four-card-feature-section-master/  section-master/                                                       ster/
        ../../FrontEndMentorsChallenges/fylo-data-storage-component-macomponent-master/                                                     ster/
        ../../FrontEndMentorsChallenges/single-price-grid-component-macomponent-master/
        ../../GameProjects/
        ../../IDLE (Python 3.8 64-bit) (2).lnk
        ../../Mozilla Docs/
        ../../Node.js.lnk
        ../../OneNote 2013.lnk
        ../../Outlook 2013.lnk
        ../../PDFMate PDF Converter Professional.lnk        
        ../../PowerPoint 2013.lnk
        ../../Projects/
        ../../Publisher 2013.lnk
        ../../Python 3.8 Manuals (64-bit).lnk
        ../../Saved Pictures/
        ../../Shallom - Chrome.lnk
        ../../Sublime Text 3.lnk
        ../../Transparent PNG/
        ../../Visual Studio Code.lnk
        ../../W3schools(offline Version).lnk
        ../../Word 2013.lnk
        ../../desktop.ini
        ../../devroad8.png
        ../../fontawesome-free-5.13.0-web/
        ../../fontawesome/
        ../../stemcoders.jpg
        ../../w3designs/

This is what I get when I run git status.


Solution

  • It appears that you have a git repository created at a very high level in your filesystem, this is not typical for git repositories.

    Option one: Add all the files you don't want tracked by git into your .gitignore file. This needs to be at the same level as the .git folder (in this case ../..) to apply to the whole repository.

    Option two: Break your repository into several smaller repositories, each corresponding to a single project. First, make sure all your files are on your local machine or can be accessed in GitHub. Then delete the .git folder in ../... Finally, initialize a git repository in each project with the command git init. (It seems like intro-component-with-signup-form-master and each folder in FrontEndMentorsChallenges would be good candidates for this.)

    I would strongly recommend option two as it better reflects how git is designed and will save you a lot of headaches down the line.