

Before you create a submodule, you should ask whether there is a better alternative available.

They’re not a perfect fit for every project. The links created by submodules will make it easier to navigate around your codebase. Submodules are a good way to link plugins and themes into your code. It makes it easy to connect different repositories together which depend on each other. , and you consent to receive offers and opportunities from Career Karma by telephone, text message, and email.Ī submodule is a link to a repository within a Git repository. Get Your Coding Bootcamp Sponsored by Your EmployerĬareer Karma matches you with top tech bootcampsĪccess exclusive scholarships and prep courses.Education Stipends for Coding Bootcamps.Best Coding Bootcamp Scholarships and Grants.Ultimate Guide to Coding Bootcamp Loans.
Update git submodule to latest commit free#
Best Free Bootcamps and Coding Training.Best Online Coding Bootcamps and Courses.If you want to see what this looks like once pushed to remote (github. Git commit -amend -no-edit # I combined this with the previous commit where I added the 'branch' value in. So finally, I did what I was trying to avoid: git add
Update git submodule to latest commit update#
You have to go and update that submodule commit reference to the latest code in the remote branch to avoid this So far, I was following the official git reference for submodules, now I decided to do some more Googling, and I stumbled an article titled Getting git submodule to track a branch, this clearly said Post this, when I ran git submodule update -remote -init -recursive, it would no longer revert my submodule's HEAD in detached state to commit A however it still kept showing the annoying modified: (new commits) So then I set the branch value as new-submodule-branch in /.gitmodules as follows If, from the main repo root, I ran git submodule update -remote -init -recursive, it kept reverting my submodule's HEAD in detached state to commit A " to discard changes in working directory) Post this, my main repo started showing Changes not staged for commit: Initially my submodule was at commit A (at the time of adding submodule to main repo), then I checked out a branch (let us call it new-submodule-branch) and made commits B and C to it and pushed it to remote () I am documenting/sharing here what worked for me. None of the answers here solve my problem. To update which commit records should be checked out for the submodule, you need to git commit the submodule in addition to committing the changes in the submodule: git add src/repo No changes added to commit (use "git add" and/or "git commit -a") (commit or discard the untracked or modified content in submodules) git status also claims submodule has untracked/modified content. Otherwise it shows -dirty hash change which you cannot stage or commit in the top-level repository. If you've already made some commits in your submodule (thus "clean" in submodule), it reports submodule's hash change. Run git diff in the top-level repository to show what has actually changed Git thinks. If you change something in submodule dir, Git will detect it and urge you to commit those changes in the top-level repoisitory. It's because Git records which commit (not a branch or a tag, exactly one commit represented in SHA-1 hash) should be checked out for each submodule.
