Why some commits aren't ok in GITLAB.COM?

I have found that my gitlab.com repository for several days silently rejecting my commits. git push origin main was always ok, but there are 8 directories aren’t committed to remote (for example FlatLaf @ 5f40ab13). They are marked in strange manner in web interface and have a reference to non-existing commits (@ 5f40ab13 for example). In the same time, git rejecting to add these directories silently, and I am not able to try to commit them once again. Please take a look at the screenshot and tell me what is going on, and how to fix it, please? Thank you!

Hi,

the screenshot and the directories look like Git submodules. When you navigate into them on your CLI, you’ll see that they follow a different Git history.

$ cd FlatLag
$ git log

$ cd ..
$ git log

Updating Git submodules requires you to 1) update the submodule repository with git push inside 2) Update the submodule pointer in the main repository.

$ cd FlatLag
$ <edit something
$ git add . && git commit -av -m "Add change to submodule"
$ git push

If you cannot push the submodule, because it is a read-only clone, you’ll need to ensure to modify it as a separate clone. Once pushed, you can do cd FlatLag && git pull.

Git submodules are configured inside the .gitmodules file in the repository. Do not edit this manually - it can break your repository. Instead, look into ways of removing them like in git - How do I remove a submodule? - Stack Overflow

Cheers,
Michael

I can’t find such file in the local copy. I have deleted a $submodule/.git directories then commited (several times) for now I have no .gitmodules file also nothing like submodules in .git/config . It seems like my repository is completely broken, isn’t is?

Hi,

if you have deleted it locally, and then committed the directories, the remote repository on the GitLab server does not know about that. The Git history between local and remote diverged, and therefore the server denies the push.

If you want to start over, delete (better: rename and keep for a while) the local copy of your Git repository, and clone it again from the GitLab.com URL.

Cheers,
Michael

This has solved the problem How to un-submodule a Git submodule? - Stack Overflow

1 Like