I am working on a Godot project that needs to import some open-source libraries. These libraries all share a particular folder structure which means that I can't directly import the projects with git submodule add
.
Here is one such library. I created my own fork of the official repo and modified it before importing. The official repo looks something like this. I want to import the quentincaffeino-console
folder from this library and add it to my project's addons
folder. (I don't want to check the files into my repository directly, I would rather keep them separate.)
godot-console
├───assets*
├───gdscript-docs-maker*
└───godot*
├───addons
│ └───quentincaffeino-console -- I want to import this folder only
│ └───src -- (and subfolders, of course)
├───assets*
├───demo*
└───etc...
* These folders contain unit tests, docs, etc. but should NOT be a part of my project
My solution was to create my own fork , delete all unit test and infrastructure files, and move the contents of the addons folder to the root of the repository:
quentincaffeino-console
└───src
Now I can add the library as a subrepo to my project :
Demo
├───addons
│ ├───quentincaffeino-console -- Created with "git submodule add https://github.com/SdgGames/godot-console"
│ │ └───src
│ ├───gut -- Another submodule created the same way
│ ├───logger -- Another
│ └───sdggames-modloader -- etc...
└───etc.
This works, but it seems a bit messy as I now have to keep multiple repository forks up to date with their upstream counterparts. Is there a way to skip the middle step and pull the folder I want into my project using a git submodule
or similar command?
Extra details:
I found some similar questions here here and here . I am NOT the owner/maintainer of the library I want to import, so I can't modify that project's structure directly.
Also, this is an open source project that runs in a CICD pipeline, so I want to keep the client side easy to understand. Right now, I can clone my project with git clone
and git submodule --init
. I will accept "git can't do that" as an answer, I just want to hear it from an expert:-)
Edit: I just found this answer from 10 years ago that says "no, it's not possible," but more recent answers seem to indicate otherwise. Is this still true today? (Sorry if it's a duplicate)
Thanks!
Is this still true today?
Yes, still true today: a submodule reference a full repository.
You can configure a submodule to be sparse-checked out , in order to display only a subset of its content (see also this example ).
But in your case, you would still need a symlink (symbolic link) in order to make quentincaffeino-console
visible where you want it in your main repository.
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.