Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Discussion .gitignore assets subfolder

Discussion in 'Getting Started' started by tleylan, Sep 8, 2023.

  1. tleylan

    tleylan

    Joined:
    Jun 17, 2020
    Posts:
    692
    I'm using GitHub for source control. It works fine except when libraries are added to the Assets folder as one typically doesn't want to check the library in. Yes we can add the folder to .gitignore and while it isn't a big deal but it does mean remembering to edit it.

    So I was wondering what methods people have opted to use. I was thinking I could add a Project folder in Assets that contained the files I did want tracked. Don't exactly know if I could exclude all folders except for that one. Alternatively I could create a ThirdParty folder in Assets and install the libraries under that. Excluding that folder would be trivial and might be the better system.

    Opinions?
     
  2. AngryProgrammer

    AngryProgrammer

    Joined:
    Jun 4, 2019
    Posts:
    490
    I think your idea is good and clean. Your options are to add folders you want to track (like you wrote above) or exclude folders (with an exclamation sign), nothing more.
     
  3. tleylan

    tleylan

    Joined:
    Jun 17, 2020
    Posts:
    692
    That's good to know. I used it on another project and it seemed to work well. But I'm having a bit of an issue deciding how to handle modifications to assets (both purchased and free). The mods need to be tracked. At the moment I place very small assets under source control. There is a reason beyond mods, a free "tree" may (I assume) disappear from wherever I got it. And I may not recall where I got it.

    Larger commercial collections of things might be updated. Depending upon what was updated and whether I need/want it my mods might no longer work. I assume keeping the library intact is a good idea and copying the parts that change into my __Project folder might work.
     
  4. But why? Do not add anything to your project you don't need. If you use it, you should add to your version control too. If you start to work with someone (or with yourself on another computer) they shouldn't need to start hunting obscure stuff to work. Check out the repo and it should work.

    If you have experimental stuff, which you really don't want to check in just yet open a separate playground project (even using the one in the version control), make sure you don't submit into version control through this and use it as it is: playground. And when you finished playing around and decide whether or not add to your main project, just move it over into your main project whatever parts you decide to keep and submit into VSC from there.
     
  5. tleylan

    tleylan

    Joined:
    Jun 17, 2020
    Posts:
    692
    Thanks. I come from a business app development background and I would say typically one does not check 3rd party libraries into source control. Particularly packages that can be restored using NPM. I would guess that libraries (purchased or otherwise) should be backed up in some way that makes them available should the library be discontinued or unavailable in some way. This is not exactly like (but somewhat akin to) not checking large binary files into source control either. A video is way too large and could potentially change too often.

    Updating libraries using NPM is easy (as is installing from scratch) and just something one typically does.

    Libraries (in Unity anyway) often have the base code, prefabs, examples and even entire scenes. They can get quite large if one needs a single prefab with a material and a couple of textures.

    That's why I'm rethinking things. Do most people check just about everything? We typically exclude editor configs and plug-ins I'm certain.
     
  6. Again, do not add garbage to your project. The solution here isn't that you exclude the garbage from the VCS, the solution is to not to add to your project. People are mindlessly add all the garbage to their projects in Unity and then they are whining why it becomes unstable, slow and inconvenient. If you have garbage libraries like that, import them in a separate playground project and move over ONLY the stuff you need. As I stated above. But shouldn't exclude them. Version-differences in 3rd-party libs and assets can be lethal to your project. The proper way to do it is to maintain control what goes into your project and when.
    BTW, yeah, I have worked in enterprise development for more than 30 years. I know the drill. Well, game development is different in a lot of aspects.

    Most people do. You shouldn't. Here is a .gitignore for Unity, what you absolutely should exclude from VCS. Obviously there are some things you also want to ignore. But any meat of your project isn't it.
     
  7. tleylan

    tleylan

    Joined:
    Jun 17, 2020
    Posts:
    692
    Thanks. I like the playground project idea. Some imports can be problematic and one can't tell until the import is done. With a test project one could get to the readme file. I like copying out the parts that matter as well because it not only limits us to the parts that we know are needed but preserves the ability to edit/modify what you have imported without worrying about what updating the library might do.

    The playground project could be placed under source control also so you know you have a version of the current library under your control. Could also be routinely backed up to a dedicated "library server" instead of course.

    I had one "video player" library that was a mess. That was the one I had to edit. Finally stopped using it altogether :)