How do I get rid of a cloned repo, within another repo?

I just made a boneheaded mistake. I was in a local repo, where the remote is on GitHub. (However, in this case I’ve not committed the change locally nor have I pushed it to GitHub.)

I wasn’t paying attention to the fact that I was already in a local repo. I went to GitHub to clone a repo I forked about 15 minutes previously. I got the URL and cloned it within the repo I was already in. Then, I realized the mistake I’ve made.

I’ve tried entering a git rm -r (folder for the repo within the repo), but that failed. (Error was “fatal: pathspec did not match any files”).

How do I either undo the repo within a repo, or delete it from the repo I put it in?

Move the inner repo directory to a “proper” location?

I think you’re over thinking things.

I hadn’t thought of that. However, I’ve already cloned the repo again to a different, proper location. So, all I need to do is get rid of that inner repo.

Just do a regular deletion for your platform (e.g. rm -rf on a Unix-ish one). git rm doesn’t work because that second repo isn’t part of the enclosing one, so there’s nothing to remove from it.

2 Likes