I am a super noob with Git. I have a folder called CSClassPrograms that I made with all my homework and labs in it. I wanted to make it a repository so I used the git init command and created and committed a master. The problem is that before I did that I accidentally made a repository for one of the lab foldders inside the CSClassPrograms folder by itself. I want to delete the second repository and make sure everything is still inside the first one. How would I do this?
Asked
Active
Viewed 1,564 times
1
-
1Possible duplicate of [How do you merge two Git repositories?](https://stackoverflow.com/questions/1425892/how-do-you-merge-two-git-repositories) – kiyah May 19 '18 at 02:15
1 Answers
2
If you don't care about the exact history within your subfolder (incorrectly set as a nested Git repo), the easiest solution is to remove that subfolder .git/
directory.
And from the main repo, do:
git rm --cached subfolder
(no trailing /: just the name of the nested Git subfolder)
From there, you can from the main repo add, commit and push: that will include the subfolder content)

VonC
- 1,262,500
- 529
- 4,410
- 5,250
-
Thank you! This helped me. I accidentally committed the main repo without deleting the inner repo, got a warning, deleted inner .git dir and commit/pushed main repo but the contents didn't show up on the remote repository. Doing this and then re-committing/pushing did the trick! – Silver Mar 16 '20 at 06:01