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

New to Unity and Git

Discussion in 'General Discussion' started by NoradZero, Mar 7, 2015.

  1. NoradZero

    NoradZero

    Joined:
    Apr 24, 2014
    Posts:
    95
    Hi there,

    I am setup with SourceTree and Bitbucket right now and i am doing some tests. I am new to Git but its seem pretty similar to what we have at the job so i know how branching/merging work.

    I am a single developer but i still wanted to use Unity with Git to have the benefit of having Version Control and avoid mess later but i have some concern while looking at some articles.

    1- About the .gitignore file. It seem there is many versions or thoughts about it everywhere. Some argue that we should include the Library folder, some say otherwise. Anyone got advices on this ?

    2-Big assets in size. What are your way of having big assets in your projects and Git ? It seem bit files aren't going well with Git.

    3- Does Git work well with scenes and stuff that aren't scripts ? Is there anything i should be aware of ?

    4- What would be the best references for using Unity and Git ? Do you guys have any that proven to work well with your setup ?

    Thanks for your advices. Really appreciated!
     
  2. DaDonik

    DaDonik

    Joined:
    Jun 17, 2013
    Posts:
    258
    I'm not an GIT expert, but the following works fine for me:

    - Go to Edit->ProjectSettings->Editor and set 'Version Control' to 'Visible Meta Files'
    - In the same window set 'Asset Serialization' to 'Force Text'

    Now you're set up and all neccessary files will be 'gittable'.

    1) I don't use gitignore on any files, as Unity generates temporary files for almost everything. You will most likely miss some files if you roll your GIT back, so i chose to git them all.

    2) I have had files up to 2gb in my GIT. Works fine but was a stupid mistake, since it was a backup of the whole GIT itself...

    3) Make sure to change the things i mentioned at the top of this post.

    4) I'm using GitExtensions which is a nice UI and works for me. Not sure if that counts as some kind of reference...
     
  3. Zerot

    Zerot

    Joined:
    Jul 13, 2011
    Posts:
    135
    read this first: http://docs.unity3d.com/Manual/ExternalVersionControlSystemSupport.html

    1) Don't include the library folder in the repo. You only need the ProjectSettings and the Assets folder in your repo. Inside of assets you can ignore the visual studio/monodevelop project files, because unity regenerates those.

    2) big files suck in general. I don't have a good solution for those and handle them on a project by project basis. (i.e. some projects do have them in the repo, some others have them outside of the repo)

    3) unity 5 has a new smart merge tool. When your serialization is set to text(I think that is the default now) you can use this for merging scene files and prefabs. http://docs.unity3d.com/Manual/SmartMerge.html
     
  4. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,886
    Here's an example of a gitgnore I used. Remember to ignore copyrighted assets. I recommend creating a folder to put them all inside like "zAssets" in my case.

    http://pastebin.com/72uBTLi2

    I used SmartGit client after trying most of the alternatives.
     
  5. NoradZero

    NoradZero

    Joined:
    Apr 24, 2014
    Posts:
    95
    Thanks for your replies guys. Was really helpful.

    @Zerot Bigs files were talking about really big files then ? (So some image which are 1mb of filesize that won't changes really in the futur shouldn't cause any problems ?)

    @Stardog I combined your gitignore with some other sample i saw somewhere. Thanks for this!
     
  6. svendkiloo

    svendkiloo

    Joined:
    Dec 2, 2014
    Posts:
    11
    Just to add a bit more on this:

    Binary files don't work well with any version control system, as they don't diff in a sensible way, and changes definitely won't merge well. This matters much less when your meta files are visible text files.

    Large binary files _may_ be a problem with GIT if they're either really large, or have loads of revisions, as all diffs of each change is included in the .git folder every user has with their checkout. But there are solutions to this, like tools such as Git Large File Support (https://git-lfs.github.com/) which seems to be the current "standard" and many others.
     
  7. larskroll

    larskroll

    Joined:
    Dec 17, 2013
    Posts:
    50
    So ... stupid question maybe, but I'm kinda a git n00b: If I ignore a directory, using .gitignore, and that diretory contains assets etc that goes into my scenes, if I then clone the project on a new machine, and reinstall the assets of the directory manually (i.e. from a USB stick, or from the asset store) it should just work ? All the linking information linking assets to scenes / prefabs is in the prefab/scene files ?
     
  8. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Probably not. It depends exactly how you have things linked.

    The Unity inspector uses GUIDs and .meta files to link between assets in your project. So if you delete and recreate the meta files, Unity will consider it a new asset and none of your inspector references will work.

    On the other hand things if the references are all set up via script things will probably still work fine.
     
    larskroll and BlueprintZ like this.