git中缺少一个文件夹,并将其作为文件推送 [英] One folder is missing in git and pushed as a file

查看:72
本文介绍了git中缺少一个文件夹,并将其作为文件推送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了很多事情将我的项目从intellij推进到Bitbucket.我必须插入两个屏幕截图来说明问题所在:一切都很好,但是文件夹"frontend"却被保留了.作为文件推送.

I have tried many things to push my project from intellij to Bitbucket. I have to insert two screenshots to explain what is the problem: everything is pushed fine, but the folder "frontend" is pushed as a file.

我确实强行推送,并尝试删除该存储库并重试,但是没有任何效果.知道我在做什么错吗?

I did force push, and tried to delete the repo and retry, but nothing works. Any idea what I am doing wrong?

推荐答案

该图标及其旁边的哈希ID意味着您所拥有的根本不是文件.(而且,Git不会存储文件夹,因此它也不是文件夹.)它是Git称为 gitlink 的东西.gitlink是子模块的内部部件,它告诉超级项目哪个 commit 退出子模块.

That icon, and the hash ID next to it, imply that what you have is not a file at all. (And, Git doesn't store folders, so it's not a folder either.) What it is, is what Git calls a gitlink. A gitlink is the internal piece of a submodule that tells the superproject which commit to get out of the submodule.

子模块本身就是另一个Git存储库.这意味着克隆超级项目后,还必须 git clone 子模块存储库.让Git自己执行此操作的指令存储在名为 .gitmodules 的提交文件中.如果缺少 .gitmodules 文件(如您的屏幕快照所示),如果文件已完成,则Git本身无法为您的子模块 git clone 子模块.我喜欢称其为损坏的子模块,有时也称为半屁股子模块.要修复它,您必须提供另一半的屁股:克隆适当的Git存储库.(然后将说明也放入 .gitmodules 文件中,以便下次完全使用.)

A submodule is itself just another Git repository. That means that after cloning the superproject, you must git clone the submodule repository as well. The instructions that let Git do this on its own are stored in a committed file named .gitmodules. If the .gitmodules file is missing—as appears to be the case from your screenshots, if they're complete—then Git itself can't git clone the submodule for you. I like to call this a broken submodule, or sometimes a half-assed submodule. To fix it, you must supply the other half of the ass: clone the appropriate Git repository. (Then put the instructions into a .gitmodules file, too, so that it's fully-assed next time.)

如果您不需要子模块,请不要使用gitlink.要使Git不使用gitlink,请确保您不尝试将存储库添加到存储库:Git实际上是 做不到的,所以它改为gitlink.

If you don't want a submodule, don't use a gitlink. To make Git not use a gitlink, make sure that you're not trying to add a repository to a repository: Git literally can't do that, so it makes a gitlink instead.

这篇关于git中缺少一个文件夹,并将其作为文件推送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆