2

I have a sub-directory that was once it's own repository that was tracking to GitHub. I deleted that repository and attempted to push it as a subdirectory to a new repository, however it will neither commit nor push to the repo. It is still tracking to the old repo. Git remote rm did not work because the repo no longer exists. I cd to the sub-directory and attempted to run git remote add origin. Now when I do git remote -v it shows:

origin  https://github.com/tjohnson1106/old-repo (fetch)
origin  https://github.com/tjohnson1106/old-repo (push)
upstream    [email protected]:tjohnson1106/new-repo.git (fetch)
upstream    [email protected]:tjohnson1106/new-repo.git (push)

I have tried git remote set-url in the subdirectory and that doesn't work, Nor does git remote prune origin. What I want is the child directory to track to the master just as it would normally. How do I remove the embedded origin repo in the child directory and have it track with parent directory in the outer repository?

2
  • Do you still have a .git subdirectory in your sub-repo? Dec 11, 2017 at 0:29
  • Yes I do, I show .git/object files. Dec 11, 2017 at 1:24

1 Answer 1

0

You still have a .git subdirectory for your sub-repository. That means that Git still recognises your subdirectory as a repository itself.

To fix this, remove the entire .git subdirectory for your sub-repository. Then Git will let you add those files to the outer repository.

2
  • This did the Job. Thank you. I would like to also point out that after I deleted the .git subdirectory I had to reinitialize git in the child folder in question. I was then able to add those files to the outer repository. Dec 11, 2017 at 22:33
  • @ThomasJohnson I am facing this issue. Could you provide a bit more details on how you reinitialized .git in the child folder ? It seems counterintuitive to me to run git init in the child folder (folder were your embedded git repository was) when you just deleted the .git there...
    – Rose
    Jul 31, 2020 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.