Say I have some code that forms the basic framework for something cool. I put it in a repo I'll call cool-app-base
.
Now, I have a few good ideas for some cool apps. I'd like them to use cool-app-base
, and build from there. Naturally, I have the options to clone
and orphan, and fork
and rename, etc. For the sake of examples, let's say I do the best thing for what I want, and create cool-app-1
.
I don't plan to contribute back into cool-app-base
from cool-app-1
, so either one would work. But I do want to be able to bring any updates I may make to cool-app-base
into cool-app-1
.
The thing is, cool-app-1
shouldn't care about the history of cool-app-base
. I want to treat these updates as squashed commits, so an update can have a commit message of "update with latest cool-app-base
" and be done. This makes fork
less appealing, but it also sounds like my only option is manually merging the cool-app-base
code changes into cool-app-1
so I can control the commit history.
My question is: How can I do this better/"correctly"? I'm sure there are some funky git merge
options I could use, but I'm not well-versed enough yet to confidently explore them.
Clarification: cool-app-base
isn't a library, but a set of config files. While they could certainly be broken up and imported individually, my intent is to maintain them bundled together. I want to have the files of cool-app-base
form the root of cool-app-1
, not be nested in a sub-directory. The actual problem I'm trying to solve is not needing to recreate my package file, directory structure, and a set of carefully-and-generically-constructed scripts every time I want to spin-up a new project. If my configs were in a sub-directory, I'd still need to create references down to them, in what I would consider just more boilerplate code.
Also, while I consider the concept to be language-agnostic, I'm working in JavaScript
with node
and npm
.
In my opinion, you can use Git Submodules , make cool-app-base
as a submodule of cool-app-1
. Then cool-app-1
will have the subfolder cool-app-base
in physical file resource, with both repository's Git history not interferenced.
Git addresses this issue using submodules. Submodules allow you to keep a Git repository as a subdirectory of another Git repository. This lets you clone another repository into your project and keep your commits separate .
You are not mention your programming language. But most languages come with some kind of package manager:
If you have such a package manager in your language use this in your app projects to include your base project.
If not, I would suggest subtree instead of submodules. You are able to include the base project into a subdirectory of your app projects. It's like copying the whole file system of one commit into another repo. You can choose if you need the history or not ( squash
).
And later on you can update to a newer version with one command.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.