One folder is missing in git and pushed as a file

穿精又带淫゛_ 提交于 2021-01-29 08:23:34

问题


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?


回答1:


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.

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.)

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.



来源:https://stackoverflow.com/questions/65135845/one-folder-is-missing-in-git-and-pushed-as-a-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!