Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity and Git

Discussion in 'Formats & External Tools' started by Fabis, Jun 26, 2012.

  1. Fabis

    Fabis

    Joined:
    Jun 19, 2012
    Posts:
    11
    I want my repository to only have the project files that Unity needs for the project to load properly and so I can work with it properly. Like, for example, in my Project folder there is the folder 'Build'. I don't need that to be able to continue working with the project. I also don't think I need the 'Temp' folder, right?

    Well, I created a completely new Unity project to see what is there from the start - the folders 'Library', 'Assets' and 'ProjectSettings'. The problem is that the 'Library' folder has files that change often and I don't think the Project really needs them to work (like there's a metadata and cache subfolder that constantly changes inside of it).

    So can you guys give me a tip or two on how to make sure that I only commit files that the project needs and don't have to commit some useless temp files every time I commit, without actually needing them.
     
  2. monstrado

    monstrado

    Joined:
    Jun 27, 2012
    Posts:
    1
    Hey Fabis94 -

    1. Make sure you have metadata enabled (Edit -> Project Settings -> Editor) and make sure Version Control is set to "Meta Files"

    2. Assuming you have a git repository created, just add the following to your .gitignore file


    # Unity3D .gitignore file.
    # Store this file at the root of your local repository.
    .DS_Store
    Library/AssetImportState
    Library/AssetServerCacheV3
    Library/FailedAssetImports.txt
    Library/ScriptAssemblies
    Library/ScriptMapper
    Library/assetDatabase3
    Library/cache
    Library/expandedItems
    Library/metadata
    Library/previews
    Library/guidmapper
    Temp
    *.csproj
    *.pidb
    *.sln
     
  3. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    Does anyone have a definitive Unity and Git guide?

    This post is the third one I've seen about Unity and Git and they all have different .gitignore files and say different things.

    ex: http://devblog.phillipspiess.com/20...nd-source-control-lessons-learned-from-7dfps/
    and http://raypendergraph.wikidot.com/using-git-with-unity3d
    and http://www.chrisdanielson.com/2011/06/04/unity3d-projects-version-control-git/

    all say different things!

    Unity say http://docs.unity3d.com/Documentation/Manual/ExternalVersionControlSystemSupport.html
    "When checking the project into a version control system, you should add the Assets and the ProjectSettings directories to the system. The Library directory should be completely ignored - when using external version control, it's only a local cache of imported assets."

    For now I'm just using a .gitignore of:

    #.gitignore file
    Temp/*
    Library/*
    Build/*

    #Un-ignore these specific files

    #ignoring pidb, they are just code completion caching data according to:
    # http://stackoverflow.com/questions/1022111/what-are-monodevelops-pidb-files
    *.pidb
    *.userprefs

    Anyone?

    ty!
     
    Last edited: Oct 9, 2012
  4. skylarjhdownes

    skylarjhdownes

    Joined:
    Sep 2, 2013
    Posts:
    1
  5. hfarazm

    hfarazm

    Joined:
    Nov 29, 2013
    Posts:
    3
  6. phyatt

    phyatt

    Joined:
    Aug 28, 2013
    Posts:
    1
    The last two links are dead. Here is the text of those using the wayback machine.

    https://web.archive.org/web/20141002071908/http://blog.hfarazm.com/git-for-unity-create-projects/
    https://web.archive.org/web/2012082...-control-lessons-learned-from-7dfps/#more-312

    #This is the git ignore file used in Duck Hunted
    #Note that ! negates an ignore. We ignore everything in Library then
    #un-ignore the metadata folder and some specific files
    #Use at your own risk, this may totally destroy your project, but it worked for us


    #NOTE: this will cause your collaborators to re-import assets periodically
    Temp/*
    Library/*
    Build/*
    #Un-ignore these specific files
    !Library/*.asset
    !Library/AssetImportState
    !Library/AssetVersioning.db
    !Library/BuildPlayer.prefs
    !Library/ScriptMapper
    !Library/assetservercachev3
    !Library/expandedItems
    !Library/guidmapper
    !Library/unity default resources
    !Library/unity editor resources
    !Library/metadata/


    #ignoring pidb, they are just code completion caching data according to:
    # http://stackoverflow.com/questions/1022111/what-are-monodevelops-pidb-files
    *.pidb
    *.userprefs



    ---------------------------------------------
    Other one:





    # =============== #
    # Unity generated #
    # =============== #
    Temp/
    Library/

    # ===================================== #
    # Visual Studio / MonoDevelop generated #
    # ===================================== #
    ExportedObj/
    obj/
    *.svd
    *.userprefs
    /*.csproj
    *.pidb
    *.suo
    /*.sln
    *.user
    *.unityproj
    *.booproj

    # ============ #
    # OS generated #
    # ============ #
    .DS_Store
    .DS_Store?
    ._*
    .Spotlight-V100
    .Trashes
    ehthumbs.db
    Thumbs.db
     
  7. TheSniperFan

    TheSniperFan

    Joined:
    Jul 18, 2013
    Posts:
    712
    You can use the Unity .gitignore preset from Github.

    Since I don't want to have binary files under version control, I wrote my own backup tool. You can specify which filetypes you want backed up and not under version control in your .gitignore file. The tool then parses your .gitignore file and recursively searches your asset directory to search for files of the specified types. It copies all files, including their metafiles and those of the directories over to another directory and - if you wish - compresses it into a zip archive.
    Here's my .gitignore file:
    Code (csharp):
    1. [Ll]ibrary/
    2. [Tt]emp/
    3. [Oo]bj/
    4. [Bb]uild/
    5.  
    6. # UBB backups
    7. UBB/
    8. unitybinarybackup.exe
    9.  
    10. # UnityVS
    11. Assets/UnityVS/*
    12. Assets/UnityVS.meta
    13.  
    14. # Autogenerated VS/MD solution and project files
    15. *.csproj
    16. *.unityproj
    17. *.sln
    18. *.suo
    19. *.user
    20. *.userprefs
    21. *.pidb
    22. *.booproj
    23.  
    24. # Unity3D Generated File On Crash Reports
    25. sysinfo.txt
    26.  
    27. # Excluded binary files #!UBB!#
    28. *.wav
    29. *.wav.meta
    30. *.ogg
    31. *.ogg.meta
    32. *.mp3
    33. *.mp3.meta
    34. *.tga
    35. *.tga.meta
    36. *.psd
    37. *.psd.meta
    This file makes git ignore wav, ogg, mp3, tga and psd files and backs them up using my tool instead.
    Since the UBB folder where the backups are created isn't actually a folder on my machine, but a symlink, all backups are automatically synched with my Google Drive. Quite convenient. ;)