![]() ![]() Let's say that we want to add a feature to our app that we have in another separate project. In addition to monorepos, we also have the concept of submodules. Your can define the shape of the data on your server and have the front-end consume it in a typesafe way. Sharing types between the back-end and front-end is a common use case. With two different repositories you could find yourself in a situation where your v1.2 front-end is asking for data from your v1.1 backend that somebody forgot to push the latest update for.Īnother big benefit is the ability to import and share code and modules between projects. If you update an API route in the server of your monorepo, that commit will be associated with the version of the front end that consumes it. The biggest benefit is that you do not need to worry about version mismatch issues between the different pieces of your project. A monorepo is simply the practice of placing multiple different projects that are related in some way into the same repository. One method of grouping code from multiple projects into one is called a monorepo. The purpose of this tutorial is to learn about some of the different ways that you can structure a large project which is composed primarily of smaller projects and modules. If you said yes to either of those things (or even if you're just anticipating encountering them in the future) then this tutorial is for you. ![]() If you want to see what this looks like once pushed to remote (github.All code from this tutorial as a complete package is available in this repository and a video version of this tutorial is available below:ĭo you work with large or semi-large codebases that are starting to get out of control? Do you have to deal with multiple different projects that interact with each other and have difficulty keeping versions aligned? 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 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. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |