Warm tip: This article is reproduced from serverfault.com, please click

One folder is missing in git and pushed as a file

发布于 2020-12-03 23:40:06

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. enter image description here

enter image description here

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

Questioner
matlab user
Viewed
0
torek 2020-12-04 08:27:05

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.