Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question about organizing files: Version Control Github - Unity

Discussion in 'Getting Started' started by FixEngine, Jul 22, 2023.

  1. FixEngine

    FixEngine

    Joined:
    Aug 24, 2020
    Posts:
    2
    Hi. does anyone know the way how to organize unity project on github like this:
    after github then, the path will be GameProjects/Car/

    Inside 'Car' file:
    .git
    Assets
    Packages
    ProjectSettings
    .DS_store
    .gitignore

    on Github.com, 'GameProjects' should be the main file, not the 'car' project name.
    What i know so far is that when making a repository on github, then the file itself is the project name. Not the file that containing many projects. If possible i want to make a file that can track many projects, much easier.
     
  2. AngryProgrammer

    AngryProgrammer

    Joined:
    Jun 4, 2019
    Posts:
    431
    I'm not sure if I understood you correctly. If you want to store many projects in one repository all you need to do is below.
    1. Create GameProjects as a repository, here will be your git files that track all future projects.
    2. In Unity Hub when you create a new project you just go to the GameProjects directory. Inside will be created project folder Car for example.
    In the above style, I create all my projects (but in one repo, one project). So I have for example "2d-sandbox" repository folder and inside is a Unity project folder "2D Sandbox".

    Edit: That was my source model with Git and Unity (look at the edition of the default gitignore file).
     
    Last edited: Jul 22, 2023
  3. FixEngine

    FixEngine

    Joined:
    Aug 24, 2020
    Posts:
    2
    Hi~, thanks for the reply. :D
    what i'm trying to say is that, i want for one repo, can have many projects, and each project can have their on git files (with Unity git ignore) if possible. (if the rules for github is that only one repo can have one set of git files, then probably not under my knowledge. )

    For the style that you mention i don't know it'll work or not since one project is kinda in a big file and without unity git ignore, can't upload the project on github.

    *and sorry for my bad english as well X3
     
  4. AngryProgrammer

    AngryProgrammer

    Joined:
    Jun 4, 2019
    Posts:
    431
    As I said you can do this by making one repo folder GameProjects, and setting many Unity projects inside in separate folders Game1, Game2, etc. You can make one gitignore (without a slash at the beginning of the directory) or just throw to each folder a separate gitignore file.

    Default ignore file from GitHub.
    Code (CSharp):
    1. # This .gitignore file should be placed at the root of your Unity project directory
    2. #
    3. # Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore
    4. #
    5. /[Ll]ibrary/
    6. /[Tt]emp/
    7. /[Oo]bj/
    8. /[Bb]uild/
    9. /[Bb]uilds/
    10. /[Ll]ogs/
    11. /[Uu]ser[Ss]ettings/
    12.  
    13. # MemoryCaptures can get excessive in size.
    14. # They also could contain extremely sensitive data
    15. /[Mm]emoryCaptures/
    16.  
    17. # Recordings can get excessive in size
    18. /[Rr]ecordings/
    19.  
    20. # Uncomment this line if you wish to ignore the asset store tools plugin
    21. # /[Aa]ssets/AssetStoreTools*
    22.  
    23. # Autogenerated Jetbrains Rider plugin
    24. /[Aa]ssets/Plugins/Editor/JetBrains*
    25.  
    26. # Visual Studio cache directory
    27. .vs/
    28.  
    29. # Gradle cache directory
    30. .gradle/
    31.  
    32. # Autogenerated VS/MD/Consulo solution and project files
    33. ExportedObj/
    34. .consulo/
    35. *.csproj
    36. *.unityproj
    37. *.sln
    38. *.suo
    39. *.tmp
    40. *.user
    41. *.userprefs
    42. *.pidb
    43. *.booproj
    44. *.svd
    45. *.pdb
    46. *.mdb
    47. *.opendb
    48. *.VC.db
    49.  
    50. # Unity3D generated meta files
    51. *.pidb.meta
    52. *.pdb.meta
    53. *.mdb.meta
    54.  
    55. # Unity3D generated file on crash reports
    56. sysinfo.txt
    57.  
    58. # Builds
    59. *.apk
    60. *.aab
    61. *.unitypackage
    62. *.app
    63.  
    64. # Crashlytics generated file
    65. crashlytics-build.properties
    66.  
    67. # Packed Addressables
    68. /[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*
    69.  
    70. # Temporary auto-generated Android Assets
    71. /[Aa]ssets/[Ss]treamingAssets/aa.meta
    72. /[Aa]ssets/[Ss]treamingAssets/aa/*
    73.  
    The final result will be such a directory tree.
    • GameProjects
      • .git
      • .gitattributes
      • Game1
        • .gitignore
      • Game2
        • .gitignore
      • Game3
        • .gitignore