-1

我一直在努力摆脱当我在我的 git bash 终端上运行 git status 时出现的未跟踪文件,它也影响了我的整个计算机系统,因为我通常会看到不同的文件以及添加到我打算的文件中的文件推送到我的 github 存储库。我需要帮助修复它。

  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/

这是我在 git status 时得到的

4

3 回答 3

0

非常简单的清洁working tree和去除方法untracked files

git clean -n // It would ask you about clean your all untracked files
git clean -f // and it clean all untracked files  finally
于 2020-06-28T12:44:57.200 回答
0

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.

于 2020-06-27T05:43:46.380 回答
0

git clean您也可以使用交互式-i--interactive-d来清理目录。

foo@bar:~$ git clean -id
  # shows a list of untracked files and directories 
*** Commands ***
    1: clean                2: filter by pattern    3: select by numbers    4: ask each
    5: quit                 6: help
What now>

现在您可以选择清理未跟踪的文件和目录。


笔记

-nor--dry-run是一个有用的选项git clean,它不会清理任何东西,只是显示会发生什么。

可以用作git clean -idn

于 2020-06-27T05:59:35.707 回答