Home > Software engineering >  How to make Git repo in a parent folder realize the a Git repo in a subfolder was removed?
How to make Git repo in a parent folder realize the a Git repo in a subfolder was removed?

Time:08-13

Let me explain the mistakes I made that led to this. For school I have downloaded some example projects for a particular coding topic that they wanted us to have. I stored them all in parent a folder where I established a git repo. The intention was to push this parent folder remotely rather than a bunch of these projects. So, I tried to go through all the example projects to remove their .git files (I imagine they were git files that the school had for their own purposes). But I missed one.

Next, I did the command "git add ." in my parent folder and committed, but I missed the warning that I've added another git repository inside a current one. I then pushed my parent folder to a remote repository, and I see that this project which I forgot to remove the .git file from is not accessible on the remote. I have since deleted the .git file for this project, but whenever I try recommitting the parent and pushing, nothing happens (it seems like the parent git doesn't detect a change) and it's still not accessible on the remote.

Do you know how I can fix this outside of straight up deleting the repos and doing it over from scratch?

CodePudding user response:

Try this:

$ git rm --cached inner_repo
$ git add inner_repo

git status should then show inner_repo as deleted and all its contents as new file. Then commit as usual.

  •  Tags:  
  • git
  • Related