嵌套的GIT Repository错误方法将其删除? [英] Nested GIT Repository mistake method to remove it?
问题描述
我刚刚意识到我错误地从子目录运行了
'git init'
命令,然后在我的项目的根目录下创建了一个主repo。
这是一个错误,所以我在嵌套的目录''上运行
'rm -fr'
命令.git'不在项目的根目录中 - 认为这可以解决我的问题(我是多么的错)
现在的问题是,当我将项目推送到GitHub嵌套文件夹变灰,就好像它被忽略一样。
有什么办法可以撤销我所做的工作吗?或者我只需要重新开始?我是新来的,并试图完成一个示例应用程序教程,但我看似毁了的目录对于在生产环境中进行部署是必不可少的。
GitHub上的一个灰色文件夹看起来像 尝试 请参阅 请注意这里的--cached选项:我们不想删除子文件夹,只有 将其标记为子模块的索引中的特殊条目 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, so I ran the
'rm -fr' command (delete) on the nested directory '.git' not in the root of the project - thinking that this would solve my issue (how wrong I was) The problem is now that when I push the project to GitHub the nested folder is greyed out as if it was ignored. Is there any way to undo what I have done? or do I just have to start again? I'm new to this and was trying to complete a sample app tutorial but the directory I've seemingly ruined is essential to the deployment in a production env. A gray folder on GitHub looks like a submodule. Try a See more at "Cannot remove submodule from Git repo" 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. 这篇关于嵌套的GIT Repository错误方法将其删除?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
git rm --cached子目录
(无尾随斜线)。
检查您是否有 .gitmodules
文件放在主repo的根目录下,并在其中包含相同的子目录。
git rm --cached submodule-name
git commit -m删除子模块条目
git push
See for instance: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.git rm --cached submodule-name
git commit -m "Remove submodule entry"
git push