Nested GIT Repository mistake method to remove it?

前端 未结 2 553
半阙折子戏
半阙折子戏 2021-01-04 19:11

I have just realised I ran a \'git init\' command from a sub-directory by mistake and then created a master repo at the root of my project.

This was a mistake,

相关标签:
2条回答
  • 2021-01-04 19:25

    I had created a submodule by mistake by using the git init command in both the parent and the subfolder. Just remove the .git directory and start over with one git init command in the proper directory that you want as the top directory.

    0 讨论(0)
  • 2021-01-04 19:31

    A gray folder on GitHub looks like a submodule.
    See for instance:

    • "What is this grey git icon?"
    • "What does a grey icon in remote GitHub mean"

    Try a git rm --cached sub-directory (no trailing slash).
    Check if you have a .gitmodules file at the root of your main repo, with that same sub-directory in it.

    See more at "Cannot remove submodule from Git repo"

    git rm --cached submodule-name # no trailing slash: not submodule-name/
    git commit -m "Remove submodule entry"
    git push
    

    Note the --cached option here: we don't want to remove the sub-folder, only the special entry in the index which marks it as a submodule.

    0 讨论(0)
提交回复
热议问题