Search Unity

Is there an easier way to save and backup a script as it progresses?

Discussion in 'Scripting' started by dennik, Dec 2, 2020.

  1. dennik

    dennik

    Joined:
    Nov 23, 2011
    Posts:
    101
    I'm used to saving different versions of files while I'm working on something, and for functioning reasons Visual studio won't allow this cause each script represents a class that interacts with other scripts based on it's unique name.
    Some times I may get carried away and update the code into something that runs like crap, and then I can't go back cause Visual Studio only gives me that many undos.

    Right now i'm copying the entire script at a stage that it works, and pasting it under a "backup" commented out region at the bottom.(after the class bracket)
    I can't say I'm too happy with this solution, so I was wondering if there is a simple way to save backup versions that are not referenced anymore when the game runs. Any ideas?
     
  2. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    2,605
    You probably want to look into a version control system like Git. First of all, your code is safe since it's backed up elsewhere. Secondly, you can create a branch when you want to test out a new feature. If it ends up well, great, just merge it into your main / development branch and continue. Did not work out? Just revert the changes, or simply trash the entire branch and check out the development branch again.
     
  3. Ray_Sovranti

    Ray_Sovranti

    Joined:
    Oct 28, 2020
    Posts:
    172
    Use a version control system (like git, for example. I recommend the "Fork" app for a git client, and BitBucket, GitHub, and GitLab are all good free hosts) This will help you keep organized without a lot of old junk files laying around (or at least, not visible ones), and you'll have a full record of your whole project file forever that you can non-destructively return to for testing or for retrieving snippets of your old code you want to keep after all.

    Using version control will also prevent you from doing a LOT of things that could otherwise irreversibly corrupt/destroy your project file.
     
  4. dennik

    dennik

    Joined:
    Nov 23, 2011
    Posts:
    101
    Thank you both for the suggestions. I'll give Git a try.
     
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,742
    Excellent. Once you've used it for a week or two, committing regularly (like whenever you get even the tiniest bit of stuff working), you will wonder how you ever worked without it.

    It's like adventuring in a hardcore permadeath RPG without using a save cartridge. Once you have a save cartridge and start saving regularly, you'll save it before you kick open a door or open a chest, etc.