Is there a way to only commit resources being used from an import to your git repo?
I've imported Mirza Beig's VFX package, but i'm only using a few things from it. is there a folder that keeps a copy of assets that are actually being used in the unity project? or do i have to manually add specific files to my git repo when I use something from an import?
I want to keep assets under version control, but ideally i don't want to version control other people's libraries. I want to either keep a link to their repo or store just the files i'm using from their library
Answer by GabLeRoux · Nov 27, 2017 at 12:19 PM
Unless the resource you’re importing has only code inside, I don’t think you can automatically only commit the used files.
If it’s only code, you could confirm classes are being used or not with dependency or usage checks but I don’t know if mono-develop provides such feature. Anyway it would be kind of useless to do this unless the library you add is very huge.
If the library you are using is also a git repository, you could add it as a git submodule by cloning it inside your repository instead of using the unitpypackage
import feature, but I don’t think this is recommended.
I recommend you simply do a commit which adds only the library.
git stash
# open unity and do the import
git add .
git commit -m "Adds 'some package name' to project"
git stash pop
Most the time, libraries have example folders you can get rid of but in fact, it can still be useful for your team so I’d keep them anyway.
At this point, you should know that unity will get rid of anything not being used by your project at compile time. Note that there are some special folders like Resources
that will still be kept in your build even if unused which may increase build size.
Edit: if you only have assets, grab one asset at the time, you'll save on the repository size and it's a good thing. Make sure you keep the License file if any and repository structure if you plan to upgrade the package.
if that's the case, i think i will create a second git repo with the imports folder and just submodule that.
i just feel like someone getting the code may not want to spend a huge amount of time downloading a GB of asset files so keeping them separate might be useful.
or maybe i'm being silly and shouldn't care whether my code repository is super huge.
Caring about repository size is a good thing. It's good to know that you can use git lfs to handle big files (since you talked about GBs of data).
If you think the unity package could disappear from the internet, you can indeed create a secondary repository for it as a backup. Just make sure you do have the right to do so and or that your repository is private. Now that I read the question again and that you're talking about assets
.
You can grab only the ones you need, I would not work with git submodules to accomplish what you want here as I think it will only increase project's complexity. Just grab one asset at the time but let your $$anonymous$$m know that other assets are available in the other repository.
Your answer
Follow this Question
Related Questions
How to restore a corrupted prefab from a VCS? 1 Answer
problems with merge conflicts for unity projects 1 Answer
Do I need to commit metadata folder files when working on version control? 1 Answer
"Open your personal git repository, and open Unity API documentation." What does this mean? 2 Answers
Visual Studio / Git / Unity - All files and folders I add are going into untracked files - why? 1 Answer