Search Unity

Unity, Github, and Collaberation

Discussion in 'Editor & General Support' started by CG-DJ, Apr 18, 2014.

  1. CG-DJ

    CG-DJ

    Joined:
    Jan 28, 2012
    Posts:
    73
    Hey Guys.

    I've been doing some research on this, but the results are confusing. I am new to Github, but I want to use it to collaborate on a project with multiple people. From what I understand, GitHub is a great solution. It will let each member of the team work on the project, and we can merge into master branches when we have all the bugs fixed, etc.

    I have just heard that having an entire project in GitHub will mess Unity up. Is this true? Is there a difference between doing this with Unity Free vs Unity Pro? Will having Unity Pro make it easier than Unity Free?

    I'm using this .gitignore file: http://kleber-swf.com/the-definitive-gitignore-for-unity-projects/

    I'm sorry if this is a duplicate post. The posts I found about this weren't answering the questions I have. Thanks for the Help! :)
     
  2. shaderop

    shaderop

    Joined:
    Nov 24, 2010
    Posts:
    942
    Only if you use Git the wrong way. But there are plenty of ways to use Git the wrong way.

    You seem to be new to source control in general. GitHub is just a hosting provider for Git, which is the actual source control system. There are many other Git hosts out there, like BitBucket.org for example.

    If you don't have someone on your team who has worked with Git before and knows how to use it, then it's probably not a good idea to have Git as your first source control system. You'll be much safer using Subversion as it is simpler to understand.
     
  3. CG-DJ

    CG-DJ

    Joined:
    Jan 28, 2012
    Posts:
    73
    Thanks for the reply. I will look into Subversion.
    Can you give an example of how to use Git wrong? I think I have it right, but I want to be sure...
     
  4. shaderop

    shaderop

    Joined:
    Nov 24, 2010
    Posts:
    942
    Sure: if two people modify the same scene file at the same time, then whoever tries to submit his or her changes last will get a merge conflict that has to be fixed. And trying to merge two Unity scene files by hand is error prone and/or time consuming.

    Actually, any time two people attempt to change a non-text asset like a scene, a prefab, an image, or a model is going to be a chance for messing things up and losing work.

    In Subversion you can get around that by locking such files before using them. Git doesn't have that ability.

    It's still not a big deal though. You can get around these issues in smaller projects by agreeing on some conventions and workflow.
     
  5. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Just wanted to chime in and say that you can also integrate Git with Visual Studio. If you're using Visual Studio 2013 it's built in, if you're using 2012 you can download the Git Tools for Visual Studio from the visual studio gallery.
     
  6. CG-DJ

    CG-DJ

    Joined:
    Jan 28, 2012
    Posts:
    73
    Sweet, that makes sense. Does developing in separate branches fix that? That would make it so that each developer is changing a separate file and then there would be no modifying the same object.

    Does the normal merge from Git not work with scenes?

    Thanks for answering my noobish questions. My project leader wants to use Git, and I'm not sure Subversion is quite what we want. I'd like to figure out a way to get Git to work, and I think I'm close. Thanks for the help!
     
  7. shaderop

    shaderop

    Joined:
    Nov 24, 2010
    Posts:
    942
    Not really. You'll still have to merge all those branches at some point. And it's the merging that is the problem.

    It can work. But the problems isn't Git. The problem is Unity. It will change the context of a scene file by moving things around, or sometimes it will give items new GUIDs. These changes make it hard for the merge algorithm to figure out how to combine the file contents since the surrounding context can change.

    I have used Git and now I mostly use Mercurial. And I would prefer Git out Subversion on most projects if I had to choose. But a Unity project (and most projects that rely heavily on digital assets) aren't typical programming projects. A lot of assets on such projects cannot be merged and some sort of locking mechanism becomes a necessity, which Subversion supports out of the box while Git and Mercurial don't.

    If you trust your project lead to know what he's doing and he believes that Git is the right choice, then I say go for it. Just be aware of the caveats.
     
  8. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    TFS also supports exclusive locks. That's what I use. The problem is that some of the files are stored binary and the versioning tools can't (easily or at all) compare binary files so that's why it can't merge them properly. If you do use a tool like Git, you'll need to make sure that two people aren't ever working on the binary assets at the same time. With TFS or Subversion this can be accomplished by checking out and locking exclusively so someone else can't check the items out and change them.
     
  9. CG-DJ

    CG-DJ

    Joined:
    Jan 28, 2012
    Posts:
    73
    Thanks for the replys, I really appreciate them.

    So, does Unity mess up when it comes to scenes and prefabs because they are built with binary files? If so, does changing the Asset Serialzation to Force Text make it so source control doesn't break stuff?

    I'm looking at subversion, but it's a little confusing. It seems I need a server so that everyone on our team can get the files. Where can I host for subversion. However, I'd really like to get GitHub to work, because I know how it works more than SVN.
     
  10. shaderop

    shaderop

    Joined:
    Nov 24, 2010
    Posts:
    942
    Yes. No. The force text option will give you the files in a format that is barely human readable, and good luck trying to make much sense of it when trying to merge two files. It's text that is almost as opaque as binary.

    You seem to be reluctant to use Subversion because it requires a central server, but you're okay with GitHub although it is a central server.

    And I think most people would agree that Subversion's model is simpler than Git's. So I'm not sure why you would find Subversion difficult to understand if you already understand Git. In fact I would say that you might be overestimating your understanding of Git if you're finding it more intuitive than Subversion.

    As I said before, if you trust your project lead and he or she believes that Git is the way to go, then go for it.
     
    Last edited: Apr 23, 2014
  11. CG-DJ

    CG-DJ

    Joined:
    Jan 28, 2012
    Posts:
    73
    I think really the problem I have with SVN is that it's site is confusing. However, I did find this tutorial site today to help! I think I'm going to try this! Thanks!
    http://pluralsight.com/training/Courses/TableOfContents?courseName=intro-to-svn