Home > Blockchain >  Deleted files showing in source control in un-related project
Deleted files showing in source control in un-related project

Time:10-17

I'm new to coding and just installed vite. I don't know if I did it correctly or anything but still learning. Right now I'm having a problem where if I delete a project in my projects folder, the deleted files start showing in my source control for projects where vite is installed. When I enter git status into the terminal, this shows up.

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        deleted:    ../manage-landing-page-master/.gitignore
        deleted:    ../manage-landing-page-master/README-template.md
        deleted:    ../manage-landing-page-master/README.md
        deleted:    ../manage-landing-page-master/design/active-states.jpg
        deleted:    ../manage-landing-page-master/design/desktop-design.jpg
        deleted:    ../manage-landing-page-master/design/desktop-preview.jpg
        deleted:    ../manage-landing-page-master/design/mobile-design.jpg
        deleted:    ../manage-landing-page-master/design/mobile-navigation.jpg
        deleted:    ../manage-landing-page-master/design/testimonials-slider.jpg        
        deleted:    ../manage-landing-page-master/images/avatar-ali.png
        deleted:    ../manage-landing-page-master/images/avatar-anisha.png
        deleted:    ../manage-landing-page-master/images/avatar-richard.png
        deleted:    ../manage-landing-page-master/images/avatar-shanai.png
        deleted:    ../manage-landing-page-master/images/bg-simplify-section-desktop.svg
        deleted:    ../manage-landing-page-master/images/bg-simplify-section-mobile.svg 
        deleted:    ../manage-landing-page-master/images/bg-tablet-pattern.svg
        deleted:    ../manage-landing-page-master/images/favicon-32x32.png
        deleted:    ../manage-landing-page-master/images/icon-close.svg
        deleted:    ../manage-landing-page-master/images/icon-facebook.svg
        deleted:    ../manage-landing-page-master/images/icon-hamburger.svg
        deleted:    ../manage-landing-page-master/images/icon-instagram.svg
        deleted:    ../manage-landing-page-master/images/icon-pinterest.svg
        deleted:    ../manage-landing-page-master/images/icon-twitter.svg
        deleted:    ../manage-landing-page-master/images/icon-youtube.svg
        deleted:    ../manage-landing-page-master/images/illustration-intro.svg
        deleted:    ../manage-landing-page-master/images/logo.svg
        deleted:    ../manage-landing-page-master/index.html
        deleted:    ../manage-landing-page-master/style-guide.md

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

So all the files I deleted show up and when I discard the changes in the Source Control panel on VS Code they get restored into my projects folder. Committing these changes only brings up something in VS Code saying ENTER COMMIT COMMAND or something like that. Any solutions?

Also side note in the un-tracked part of the terminal message a bunch of other projects from my projects folder show up for some reason. Any solutions in having that not be the case? I don't think they're supposed to show there.

CodePudding user response:

It looks like you initialized your git repo at the level of your projects folder. (I'm going to call it projects from here on).

(btw, read until the end before running any commands.)

To confirm this diagnostic, cd to projects. Then run ls -a and look for a .git directory. If there's one, then your entire projects folder is a git repository.

If that's the case and it's not as intended, you should remove that .git directory.

But before that, ask yourself if you want to preserve the git history (commits) of that repository.

It's possible to preserve the commit history for each project within projects, but it's quite a bit more involved. Ask again if you need that.

Once you have decided to do away with the outer projects repository, run rm -rf .git from within the projects folder.

That line stands for remove --recursive --force the .git directory. You can try without the --force first to learn why that's necessary.

Everything related to a Git repository lives in that .git directory, so now it's like it never was a Git repo. You can check that by running git status

From now on, you should only run git init from within a particular project's directory, never the outer projects

  • Related