Search Unity

Version Control, You, and why You need Version Control

Discussion in 'General Discussion' started by AndrewGrayGames, Nov 14, 2013.

  1. calbzam

    calbzam

    Joined:
    Jan 3, 2014
    Posts:
    2
    Hi,

    Plastic allows you to work in a fully distributed way: (http://www.plasticscm.com/features/distributed-version-control.aspx)
    You can have a repository server on each developer's machine. So every team member can go disconnected and synchronize on demand. It's very useful when you want to work at home, or you perform a quick fix at a customer site, or you simply don't want to rely on the network for every SCM operation you perform.

    Anyway, you can run GitSync feature on a Mac too. Check this video to see the process (is the same on a Mac installation)
    ( http://www.youtube.com/watch?v=fVpaoLBLimU )

    Regards,
    Carlos
     
  2. Zelek

    Zelek

    Joined:
    Jun 12, 2010
    Posts:
    87
    I spent the evening getting PlasticSCM up and running on my Amazon EC2 instance, and I'm pretty happy with it. I don't have the Team License, so I'm using the PlasticSCM GUI client, but things seem to work as expected. The one downside I'm running into (on the Unity side) is that running my project after adding just a single comment to the code seems to result in 2 to 3 dozen arbitrary files being modified.

    This might get annoying further down the road when I'm trying track down specifically what changed between two revisions. Is it generally going to be limited to the Library folder, and I can just ignore changes in there? After using version control for other non-Unity projects and having a nice clean changeset history to look through, all this clutter is really bumming me out.
     
  3. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,657
    The Library folder should never be committed to version control. Once you've turned on visible .meta files, you should only commit the Assets folder and the ProjectSettings folder.
     
  4. Zelek

    Zelek

    Joined:
    Jun 12, 2010
    Posts:
    87
    Ah, that's great news then. Thanks, superpig!
     
  5. AndrewGrayGames

    AndrewGrayGames

    Joined:
    Nov 19, 2009
    Posts:
    3,821
    I did not know that. Thanks for the info.
     
  6. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    Also check out the Git Ignore files for Visual Studio solutions. They give you clues on what to not push to your repository.
    Here is a link to one..
    http://kleber-swf.com/the-definitive-gitignore-for-unity-projects/

    No matter the source control you use though, you can apply similar rules.
     
  7. code-blep

    code-blep

    Joined:
    Oct 1, 2010
    Posts:
    308
    Well I gave Plastic SCM a go but it seems like overkill for my needs, to the point that there are so many options I am back to the old problem, as in I don't trust it. I know that sounds weird, but the more options there are the less confident I am that everything is set-up correctly, and the sense of it being out of control increases. With that the fear of the SCM inflicting it's own brand of disaster increases.

    I am a one man studio so I don't need to manage versions between other developers etc.

    I don't want to give up on SVN as it makes perfect sense. Does anyone have any suggestions for a baseline simple Version Control software that integrates with Unity and will sync with BitBucket?
     
    Last edited: Jan 17, 2014
  8. AndrewGrayGames

    AndrewGrayGames

    Joined:
    Nov 19, 2009
    Posts:
    3,821
    I remember some talk of a way to perform Git operations within Unity a while back. If there isn't, then I think probably some form of Windows shell extension like TortoiseGit or TortoiseSVN will be your best bet. If you're not on Windows...well, you're out of luck as far as 'presented with relatively few options' is concerned.
     
  9. code-blep

    code-blep

    Joined:
    Oct 1, 2010
    Posts:
    308
    Fortunately I am on windows, and currently looking at SourceTree (with Tortoise next on the investigate list).

    I am also looking at Version control for my day job (web design / development) so I'm trying to find one that will suit both environments if possible. I'm determined to get something working!
     
  10. Tanel

    Tanel

    Joined:
    Aug 31, 2011
    Posts:
    508
    I use TortoiseGIT with Unity stuff and am satisfied with it, though some integrated solution would be nicer (without having to buy the team license).

    If you use some IDE for webdev chances are they have git and/or mercurial integrated (Aptana Studio, Netbeans, PHPStorm etc. ).
     
  11. Vanamerax

    Vanamerax

    Joined:
    Jan 12, 2012
    Posts:
    938
    I am running Mercurial with SourceTree and BitBucket. Works like a charm, was very easy to install and set up and is really user friendly and easy to use. A nice tutorial on how to get started: http://makegamessa.com/discussion/811
     
  12. AndrewGrayGames

    AndrewGrayGames

    Joined:
    Nov 19, 2009
    Posts:
    3,821
    Thanks! I'm starting to look into Plastic a bit. Since I'm in between project, I figure I can finish those Git tutorials that I never got around to finishing...
     
  13. SVGK

    SVGK

    Joined:
    Jan 25, 2014
    Posts:
    99
    i don't really understand any of this, i can only just about understand the basic idea of it, and even then i'm not so sure, what exactly is version control?, from what i've seen here, it's most useful for when multiple people are working on something.
     
  14. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    No, version control is extremely useful even if it's just you.
    Here are some benefits if it's only you working on the project..

    1.) It gives you an online backup of your project. So if your house blows up, you can still retrieve your project from your source repository. I hear of many people making 'daily backups' to a USB or another hard drive. Not only is this inefficient, but If your house gets cleaned out by thieves, or blows up, you lose all this data. Github and BitBucket are two online source repositories that will always keep your data safe in a remote physical location.

    2.) This online backup is extremely efficient, because it only pushes the files you change each time. It doesn't do an entire backup.

    3.) You can go back to any point in time of any file. Lets say one of your Unity scenes corrupt, or you changed an image, or modified some source code, and you want to restore a specific version of that file for some reason, having an online source repository allows you to do this.

    My personal preference is using Github.com to store my repositories and for a GUI client I use SmartGit (which has a free version)
     
  15. SVGK

    SVGK

    Joined:
    Jan 25, 2014
    Posts:
    99
    i'd imagine my house blowing up would kill me, and i live in the middle of nowhere and rely on a satellite connection to reach human civilization, so thieves are even less likely than most places.

    though kidding aside, i see what you mean, i suppose pushing the files means that it only makes uploads files that have had some changes made to them.

    this seems very useful then, all i need to do now is learn the terminology and how to actually do it.
     
  16. Smooth-P

    Smooth-P

    Joined:
    Sep 15, 2012
    Posts:
    214
    Thinking of something like git as "Version Control" is selling what git does way, way short. It's not anything like just saving backups, even if you had infinity * infinity USB sticks spread all over the world.

    Thinking of git as "Change Management" is much more appropriate. And everyone makes changes. And everyone should be using something that helps them manage those changes.
     
  17. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    We use SVN repos on CloudForge via Cornerstone on MacOS and TortoiseSVN on PC.
     
  18. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,619
    Huh?

    I get what you're saying in terms of making the purpose more obvious from the name, but don't "version control" and "change management" mean the same thing anyway? The difference between "versions" is that some "change" has been made, and the entire purpose of these tools is to help you "control" or "manage" those changes.
     
  19. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    Change management usually refers to a level of management in an organisation that determines the impact of changes and the parties that need to be involved in order to facilitate this change with minimum impact or downtime.

    It's usually in organisations with mission critical or large incomes. I don't think you can call source control change management. Version control is a more accurate term.
     
  20. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,619
    That's a good point. "Version control" is a far more context-specific term. "Changes" can happen pretty much anywhere to anything, where "versions" are specific to certain forms of work.
     
  21. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,657
    BTW, I learned recently that it's actually against the Bitbucket TOS to store non-code assets in your repo there. If your project is only tiny then they may just not notice but be careful if you're thinking of hosting a larger project there, especially if you're hoping to use the free tier - if they notice then they will lock and delete your repo.
     
  22. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,619
    Wow. I wonder if that's a change or if I missed that to begin with. While they certainly discouraged it when I signed up I'm pretty sure that they didn't outright forbid it. I haven't used it for a while to notice any changes, though.
     
  23. Smooth-P

    Smooth-P

    Joined:
    Sep 15, 2012
    Posts:
    214
    Changes are what I make to code, what I commit, what I discard, what I stash, reorder, squash, merge...

    Versions are what people keep on USB sticks and think is just as good as proper source control.

    Shall we now start talking about what MBAs define as "source", "control", and "system"? :rolleyes:
     
    Last edited: Feb 17, 2014
  24. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,619
    ... and are what result in different versions.

    Are you a "programmer"/"software engineer" or a "typist"? Typing is what I do to generate code... ;)

    Haha, clearly you couldn't actually argue the point here. The point isn't that we don't make changes (or that we're not typists), it's that "version control" is a better term since "change control" could literally apply to anything. Someone could apply "change control" to their code without going anywhere near any kind of "version control" tool.

    Version control is a type of change control. Change control is not necessarily version control.
     
    Last edited: Feb 17, 2014
  25. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    So if you have a 5GB project how many 5GB 'version' backups do you keep?

    And no it is not 'just as good' as source control. Because with source control you're not making a 5GB version backup each time, you only keep track of changes, which is far more efficient than making a 5GB backup each time, or unpacking that 5GB backup file to get to one specific file you wish to restore.
     
  26. Smooth-P

    Smooth-P

    Joined:
    Sep 15, 2012
    Posts:
    214
    The point, since you've clearly forgotten what the first 6 pages of this thread are filled with, is that many Unity devs equate "version control" with "saving old versions", when a proper source control system does far, far more for you than that.

    And in fact, unless you're throwing in binaries, good source control systems aren't based on versions, they're based on changes and change sets. A version is something you get by applying a sequence of changes.

    When you go back and look at previous commits, what are you usually more interested in, the entirety of the code base that makes up a version for a specific point in time, or the changes that made up the commit?

    But, hey, if you're more interesting in arguing about whether "versions" or "changes" or "typing" is better term for what something like git tracks than actually getting people to understand what git does and why it's far better than USB sticks... well, yeah.
     
    Last edited: Feb 17, 2014
  27. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,619
    Haha, didn't you start this particular sub-discussion? I'm pretty sure you did...
     
  28. Smooth-P

    Smooth-P

    Joined:
    Sep 15, 2012
    Posts:
    214
    Yep, someone specifically asked what version control does and I replied you should think of it in terms of changes, not versions. Because changes are what scm actually tracks, and is why you can reorder changes, merge them, partially apply / roll back, discover conflicts, stash them for later, branch, etc, etc, and that's why it's powerful and important even as a solo developer.

    And I will stand by my posts and even embellish with more actual information for the "saving old versions, I work solo and have dropbox and USB sticks!" crowd:

    When you go back and look at your project history in scm, you don't don't look at "versions" of files that start with "using UnityEngine;" (though of course you can look at things in that way if you want to), you see "changes" like:

    Code (csharp):
    1.  
    2. Date: 2014-02-16 20:34:08
    3. Message: Fixed sqrt when explosion is above player and dy is negative!  Whoops!
    4.  
    5. lines 52-56:
    6.  
    7.          var distance = player.position - explosion.position;
    8.          var dy = distance.y;
    9. removed: var damage = Mathf.Sqrt(dy);
    10. added:   var damage = Mathf.Sqrt(Mathf.Abs(dy));
    11.          player.ApplyDamage(damage);
    12.          player.CheckIfDead();
    13.  
    And you can easily hit a button to "undo" this change, and only this change, if you want, which wouldn't be very helpful in this case but is extremely helpful with more complex changes / changesets. Hell, it's extremely helpful even just to go back and see what you did!
     
    Last edited: Feb 17, 2014
  29. Dbone

    Dbone

    Joined:
    Mar 10, 2014
    Posts:
    56
    OK, I swear I'm really close to understanding this whole concept... :eek:

    Just a few questions:
    I'm developing with 1 other person remotely. We are both generalists although I do more art and he does more programming. If I set up a Plastic SCM account for version control do we still work on the same set of files stored somewhere magical, or do we work on different LOCAL sets of the same files and then they get merged someplace magical into some master file that you never directly modify? Where is that magical place they get merged? Is it on Plastic's server? Do I need to set up another place? What are the concerns with large art files?

    Thanks so much for this thread, the fog is starting to lift...
     
  30. AndrewGrayGames

    AndrewGrayGames

    Joined:
    Nov 19, 2009
    Posts:
    3,821
    I don't know plastic, but I do know Git.

    The answer with all version control schemes, is wherever you decide the remote repository should be. In my case, I favor BitBucket or GitHub, as they're easy to use and point my versioning client to. You could have an older computer in a relative's house that you designate to be the off-site repository; it really dosen't matter, you're storing data in more than one place(s) at once, which allows you greater ability to recover from a particularly devastating event.

    Also, the way Git works, is it locally stores changes you've made as well, allowing you to locally choose where you're working from (it's actually more complicated than that, but hey - the fog's lifting, I'm not gonna do a rain dance now.)

    The takeaway? Choose a place to store your data. I'd actually recommend someone else's servers, as they typically take good care of them and have additional options for ensuring that your data survives.
     
  31. NTDC-DEV

    NTDC-DEV

    Joined:
    Jul 22, 2010
    Posts:
    593
    You can also use GitHub as a server and use the simple PlasticSCM GUI as the client ;)

    http://plasticscm.com/gitsync/index.html

    Also, read up on DVCS and CVCS (Distributed vs Centralized) Version Control Systems. What's awesome with Plastic is that its YOU that decides if you want to do DVCS or a mix of it with CVCS or whatever you want for your project. It's the way you setup it that's going to decide it with your own preferences.

    https://blogs.atlassian.com/2012/02/version-control-centralized-dvcs/

    ;)
     
    Last edited: Mar 11, 2014
  32. Dbone

    Dbone

    Joined:
    Mar 10, 2014
    Posts:
    56
    I would definitely set up a distributed system, honestly can't think of any advantages to go centralized.

    The chances of me modifying code while the 1 other guy I work with is also doing it are virtually nil, but eventually there will be more people so it seems like getting used to a system now is the way to go which is why I'm learning.

    I would like to set up a version control system without needing to buy and set up a Windows server. I don't understand if GIThub or other things replaces the need for a Windows server. If so, do they host your files? What about large art assets? How much storage is there?
    This is really the only issue stopping me from going version control rather than saying "@#%@ it, Dropbox is fine for now". I just can't seem to find information on the options for where stuff is stored and where things need to be served out from. Does everyone who uses version control software also use a windows server to store and distribute it? What about a NAS? What about keeping the source in online storage, and working distributed? What about serving out from one of the working computers in a distributed environment with an online backup?

    I read forums like they're going out of style but can't figure this out.

    Thanks so much for all the help so far!
     
    Last edited: Mar 12, 2014
  33. NTDC-DEV

    NTDC-DEV

    Joined:
    Jul 22, 2010
    Posts:
    593
    Depends on what you want.

    You can very easily install a MySQL server for free on any windows machine, hook it up to your LAN and connect to Plastic as an example.

    Took me 1h and all the guides were on Plastic's website. Depends on your needs, bandwidth and if you want to work local or through VPN or purely distributed on internet.

    Distributed is awesome if you're not on the same network but loses much of it's advantages if the CVCS is fast. I mean, what is DVCS other than having a complete copy of the repo locally, can work without constant server connection and have greater branch merging control (at least with a git-type pull/push request approach). CVCS is just simpler to use and understand, mostly for artists.

    CVCS has a bad rep because most solutions have horrible branching / merging mechanisms, are freaking slow and require constant server access. At the end of the day, if you can do exclusive checkouts, branch-out at will, have a half-brained workflow and a fast connection to the server... you're in business for Unity development on a small-mid scale with CVCS.

    Remember, most programmers are used to code-only projects. I know I was, coming from web development... it was painless. Add a bunch of Unity scenes with no merging, Gbits of 3D assets and other binaries... put artists in front of the VCS and tell them to start pull/push, commit, merge, conflict resolve and branch. Then you'll understand why DVCS and CVCS is no longer relevant as a question and not one is better than the other.

    Just keep it simple-stupid.

    FYI, if you want distributed;
    http://plasticscm.com/guides/distributed/main.shtml#Chapter1:Overview
     
    Last edited: Mar 12, 2014
  34. Dbone

    Dbone

    Joined:
    Mar 10, 2014
    Posts:
    56
    So you need an MSSQL server (would mySQL work?) to use Plastic? There are no online services that cover that need AND offer file hosting? I have a NAS with mySQL but it is not Windows based, possible?
     
  35. NTDC-DEV

    NTDC-DEV

    Joined:
    Jul 22, 2010
    Posts:
    593
    Read up on Plastic a bit first if that's what you want, I cannot tell you if one solution is better suited for you over another...

    They support tons of server setups including online repos from service providers.
    http://www.plasticscm.com/infocenter.aspx

    Depends on if you want to setup yourself the server or not. Downside is some maintenance and a bit of a learning curve, up side is complete control, its free and you can have it on a local LAN.

    I cannot tell you what to do exactly but I can tell you that compared to 5... 10 years ago, it's practically plug play for most parts. All the info is there in the guides and tutorials.
     
    Last edited: Mar 12, 2014
  36. Kinos141

    Kinos141

    Joined:
    Jun 22, 2011
    Posts:
    969
    Good this post resurfaced, because I have a question. What exactly should I upload on a version control from the Assets folder? I know my scripts definitely should go up, but what about assets? Uploading them would take some hours max to get all of them up(not counting the bought assets that should not be uploaded).
     
  37. NTDC-DEV

    NTDC-DEV

    Joined:
    Jul 22, 2010
    Posts:
    593
    When you version control the entire asset folder, be mindful that most of your non-code assets (Binaries) won't be merge-able. So you'll need to do exclusive checkouts or coordinate between yourselves if you're modifying, for example, a Unity scene.

    I do recommend you put the entire project there as per Unity's version control guide (so don't put the library folder!). Because if you start changing the code for MonoBehaviour X that is a component in Scene Y and you don't have your assets scene versioned when it's modified... you'll be in trouble when someone modifies it later on with different dependencies. Always better to have your change-set 100% compatible with all assets.
     
  38. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    Get a GitHub account, and download SmartGit, a free UI for connecting to git repositories. Make some test repositories with some small Unity projects and put in some test scripts and assets and get your artist to connect to it to. Do some changes etc and see how it all works.
     
  39. tigerija

    tigerija

    Joined:
    Mar 26, 2012
    Posts:
    60
    I noticed there are some free version control services that are private.
    Can anyone suggest something that is good and safe?

    Thanks.
     
  40. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    If this existed as you envision it above, you'd realize it was a terrible idea after you needed to use it for about 5 seconds. What about if you wanted to go back to the version 2 weeks ago, when you broke something without realizing it. Would you like the user experience of hitting undo 786 times to get to that version?

    Versions mean nothing without a check-in comment that you type in to describe it. In your system, this wouldn't even exist. So you have no idea which version you're going back to with undo #1 or undo #1000.

    Normal SVN flow: You make about 100 changes to the level / prefabs and say:

    Now I've got everything working, I'd like to make a SINGLE check-in for a single version, and I'll put "Added extra attack wave on level 2" as the comment (and you can see a list of versions and their comments on the history window). You don't care about tracking the other 99 changes because those are all broken or partial steps. Recording every single change would be monstrous and there's no need to do that. You decide when to make a new version, and you have to label it or it means nothing.

    Also, SVN allows you to completely revert all changes made in a single check-in with 2 mouse clicks. Say you added a new plugin to the project. Okay, that's worthy of a check-in. It modified/added 50 files. If later that plugin proves to be a problem and you don't want it any more, piece of cake. Go find the version and choose "revert changes from revision" and check in again. Voila!

    And you can go back to any version with a couple mouse clicks. Even if that was 500 versions ago.

    By the way, I'm the only programmer in my company, but we have many artists / modelers / sound people etc that all use SVN. It's not a programmer-y thing at all. It's common sense.
     
    AndrewGrayGames likes this.
  41. BeefSupreme

    BeefSupreme

    Joined:
    Aug 11, 2014
    Posts:
    279
    Well, this thread and a few others have convinced me to give it a go. I'm terrible at all things networking, and it seems needlessly complicated, but worth it in the long run I guess. I think I'll try either Assembla + Tortoise SVN, or Bitbucket + Tortoise Git and see how it goes. I heard that git is a better choice if you aren't going to be connected to the internet 24/7, any truth to that?
     
  42. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I'd go for Tortoise SVN + hosting by Project Locker. They have by far the most reasonable rates we've found.
     
  43. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    I have problems with scenes. Every time I change the smallest thing in a scene, or even start and stop the scene, unity like to make a lot of changes to it unrelated to what I changed. Therefore merging scenes is a royal nightmare. Our chat is littered with "Can I have the scene now?" messages, which is just ridiculous.

    This also makes it really difficult to do branches, and copy changesets between branches, which I really love.

    I use mercurial with bitbucket, but the same thing would happen with subversion or git. I also set the scenes to store in text format.

    Anybody has this problem?
     
  44. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    That's a Unity problem, nothing to do with which version control system you use. To get around this, make everything in the Scene a prefab. Then you can modify prefabs but not need to modify the Scene unless you add or remove something from it.
     
  45. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    Yes, I am aware this is a unity problem. I do keep everything as a prefab, but unity still insists on changing the scene when I change a prefab and apply. Also, this does not help when a gameobject has a reference to another gameobject in a different prefab.
     
  46. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    It insists, but you don't have to say "yes, save it" when it asks. The changes will be saved in the prefab anyway and it will work.

    I wish they would change it, it's a fundamental problem with Unity that makes it hard to work on anything but very small teams.
     
  47. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    Yes, git keeps all the data in your computer, so you can use most of the functionality while offline. Subversion on the other hand only keeps the latest version in your computer, so if you want to browse the change logs, switch to branches or just commit, you need to be online.

    I would recommend you use either tortoisehg + bitbucket or tortoisegit + bitbucket. Mercurial (tortoisehg) tends to be a little more user friendly. git tends to be more powerful. But they are both very similar and either one will probably work for you.
     
  48. BeefSupreme

    BeefSupreme

    Joined:
    Aug 11, 2014
    Posts:
    279
    Awesome, thanks.
     
  49. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,619
    I know I used to recommend BitBucket, but their terms states that you're expected not to store large hunks of binary data. That more or less rules out game development...
     
  50. BeefSupreme

    BeefSupreme

    Joined:
    Aug 11, 2014
    Posts:
    279
    Do you have a link by any chance? I just skimmed their user agreement and terms of use and all I really saw was:

    Consuming an unreasonable amount of storage for music, videos, pornography, etc., in a way that’s unrelated to the purposes for which the services were designed

    But would like to make sure before using it.