Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Minecraft - Versioning your saves

This is a tutorial show how to version your saves using Git.

Q: Why would anyone go through this process?
A: Because if you do, you can undo an otherwise un-undoable action, such as swimming in a pit of lava and accidentally dropping your Notch armpit forged special edition diamond pickaxe and your 35 stacks of cobblestone.

Step by step tutorial

Download and install the appropriate version of Git

  • Linux
    • Ubuntu/Debian
      1. sudo aptitude install git
    • Other dists
      1. Use the source, Luke.
  • Windows
    1. Download msysGit
      I would choose the "Full installer for official Git 1.7.4" -- or in a few years; "Full installer for official Git \d(.\d(.\d)?)?"
    2. Install it!
  • Mac
    • I'd love to provide more details, but I do not have access to a Mac OS X environment.
      Installers are found on the git-osx-installer download page. I wish you good luck even though I am sure it is no more confusing than the Windows installer.

Find your saves directory

  • Windows
    • As described in a post on the Minecraft forum
      1. Open "Run" from the start menu
      2. Enter %appdata%/.minecraft/saves in the box
      3. Press RETURN If this does not take you to a folder looking somewhat like this, check the forum thread for further directions.
        My saves folder
  • Linux
    • I can't confirm this, but I suspect it might be in $HOME/.minecraft/saves
      A StackExchange Gaming post confirms that the save folder is indeed located at ~/.minecraft/saves
  • Mac

The worlds are all logically named after this view in minecraft:
My minecraft saves

Set up the git repository

If any of the things mentioned in this section should spawn questions in your head that you absolutely want answered, try the Git Immersion git tutorial. It will teach you git from the bottom and up.

If the Git Immersion tutorial does not answer your questions, try Google. There is an almost infinite amount of posts, discussions and manuals available to answer your questions. Some of them do it better than the others.

This chapter and the following pages of the Git Immersion tutorial concerns the points mentioned in this tutorial.

The only difference between this case and the cases mentioned in the Git Immersion tutorial is that we are mostly dealing with binary files and not text files.

  1. Fire up your command-line interface.

    • Windows
      • StartProgramsGitGit Bash
    • Mac
      • Spotlight ⇒ Search for "Terminal" — Or something similar to this
    • Linux
      • Well, duh. Hints: "Terminal", xterm etc.
  2. Change the current working directory for your command-line-interface to the appropriate World[1-5] folder in the saves directory

    cd /c/Users/YOURNAME/AppData/Roaming/.minecraft/saves/World1
    

    for World 1.

  3. Initialize the git repository

     git init
    

    git-init

     # Notice the dot
     git add .
     
     # You might add -s after, If you have set up your user.name and user.email values in your git configuration
     git commit -m "Initial commit"
    

    git add . should output nothing but a blank space. git commit [...] should output something like this
    git-commit

You now have a snapshot of your selected minecraft world.

The correct way to do something really stupid and unnecessary

  1. Run

    git add .
    git commit -m "Before stupidly walking into lava, an event which I have not at all planned. This is just in case"
    

    This creates a new save point for you, a savepoint that you can revert back to.

    By running

    git log
    

    you should be able to see the "savepoint" or commit, as git calls it. Mine is called "Befor(e) dying". git-log

  2. Load your world

  3. Do something clumsy, unfortunate or just plain stupid.
    found-lava
    fffffffuuuuuuuuuuuu

  4. ?????!?!?!?!

  5. Run

    git log
    

    this will show you the most recent commits with the most recent commit at the top
    git-log

    You will need the SHA1 value that is associated with the specific commit. In this case 07c1925969e2bd30fa4e940656c7ab8573f1ddb0.

  6. Run

    git reset --hard y0ursha1c0mm1774gv41u3
    # WARNING: This step is to my knowledge irreversible; once you back, you never go back.
    

    this will return

    HEAD is now at l0l0l0l Before stupidly walking into lava, an event which I have not at all planned. This is just in case
    

    git-reset

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.