gitgithub

What is a subproject commit?


I'm trying to add the Laravel files to a Github repo.

I ran

$ git clone https://github.com/laravel/laravel.git

The files show up fine locally but do not show up when I push to github:

enter image description here

The commit shows:

enter image description here

How can I add the laravel files to my github repo? Also, what is a subproject commit?


Solution

  • A submodule commit is a gitlink, special entry recorded in the index, created when you add a submodule to your repo;

    It records the SHA1 currently referenced by the parent repo.

    A git submodule update --init is enough to populate the laravel subdirectory in your repo.

    Once it is filled, note that your submodule repo is in a detached HEAD mode.

    As shown here, when switching branches in the parent repo, your submodule gitlink will change accordingly, but your submodule content won't change until you make again a git submodule update (after the git checkout)


    I don't think this answers the question.

    It does in the context of why the files aren't showing up on GitHub: The OP was about the "subproject commit" and the issue of Laravel files not showing up in the OP’s GitHub repository after a push.
    This is caused by the Laravel folder being added as a submodule, not as a regular set of files. Hence, my explanation about gitlink and git submodule update --init

    The OP is trying to add the files to the repo and not clone from the repo.

    True: the OP may not want to use submodules at all, but add the Laravel files directly into the repository.

    In that case, you would need first to remove the submodule:

    git rm --cached laravel
    rm -rf .git/modules/laravel
    

    And manually add the Laravel files. Since the files are already present locally (because of the clone), simply stage and commit them as part of the main repository:

    git add laravel
    git commit -m "Add Laravel files directly to the repository"
    git push origin main