Search Unity

PSA, Global Git Ignore

Discussion in 'Open Projects' started by MileyUnity, Oct 6, 2020.

  1. MileyUnity

    MileyUnity

    Joined:
    Jan 3, 2020
    Posts:
    92
    Hey everyone, I wanted to give you all a quick PSA regarding the .gitignore file.

    A quick explanation for those who don't yet know what a .gitignore file is, the .gitignore file is a file that defines what files git should not see as changed when you're about to commit something. There is currently a generic Unity .gitignore file in the project which ensures that the library, obj, logs and other data that isn't required for the project to be re-build will not be added to git. This both helps keep the git history clean and avoids the project from getting too big to host.

    Since we're most likely using many different IDEs to write code for the project you might think that it would be a good idea to add any files specific to your IDE that it generates in the project folder to this general .gitignore, the problem with that is that this file would then grow quite big in order to support all the different IDEs that may exist which isn't really a clean approach. Instead you can create a local global .gitignore file, this would ensure that your IDE specific files don't get pushed to any repo on that machine anymore and keep the shared .gitignore cleaner for everyone else.

    You can find a guide on how to achieve this here, https://gist.github.com/subfuzion/db7f57fff2fb6998a16c

    Myself I use Jetbrains Rider and thus my global gitignore is simply this

    .idea/


    And after this change I no longer have to watch out for accidentally adding the .idea folder in my commits without having to alter the gitignore of the project. To know exactly which files to ignore for your IDE you can simply find it on Google. Hope it helps!
     
    Zold2012, tmcdonald and JoNax97 like this.
  2. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    481
    Anyway, it would be cool to have in .gitignore most common IDEs: VS Code, Visual Studio, Rider.

    Rider gang:cool:
     
    TomateSalat and Neonage like this.
  3. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    481
    And... I can't find anything related to Git LFS. That's weird...
     
  4. cirocontinisio

    cirocontinisio

    Joined:
    Jun 20, 2016
    Posts:
    884
    In what sense? We're not using LFS on this repository.
     
  5. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    481
    But why? This is a game project with binary assets like models and textures and LFS created exactly for such things.
    Just curious:)
     
  6. cirocontinisio

    cirocontinisio

    Joined:
    Jun 20, 2016
    Posts:
    884
    LFS is sometimes hard to setup on the end user's machine, and can lead to mistakes that are hard to fix.
    Plus, monthly bandwidth on Github is limited, and we would consume it pretty quickly.

    The "low-fidelity" of this game (for instance textures should be relatively light) should allow us not to go over 100MB per asset, which is the limit for non-LFS Git. Hopefully we won't go overboard with scene size.
     
    MUGIK likes this.
  7. Erenquin

    Erenquin

    Joined:
    Apr 9, 2018
    Posts:
    164
    There is a git repo with kind of default gitignore files.
    Thought it would help.
    https://github.com/github/gitignore

    See also the community and Global sub directories if you do not find what you are looking for in the root.
     
    cirocontinisio likes this.