Git Tutorial #Bonus

Repository of a Ren'Py Project, .gitignore

I've been trying to keep the Git Tutorials very generic. While created for programmers, other creators can take take great advantage of Git as well - especially writers. It's less useful for artists or composers, but if they are willing to go through the learning process as well, it can be a valuable skill in collaborations.

Still, LezCave is a website focused on Ren'Py content. As a bonus tutorial, I would like to show you how I like to prepare my repositories when creating a new Ren'Py project. First, I always create a .gitignore file, a special file which lets us specify which files will be ignored by the Git. Then, I make several starting commits, to start tracking the default files.

Let's take a look at something you're most likely familiar with: Files of the newly created Ren'Py project. We're currently in the base project folder, where we'll be creating the repository.

The game folder is here, as well as three text files. log.txt changes with each project launch, while errors.txt and traceback.txt change with errors or exceptions encountered.
They aren't created with the project, but I'll need them for the demonstration process, so I've gone ahead and created them myself.

When you initialize a new repository inside GitHub Desktop, it creates a new folder. If the folder already exists, it automatically starts tracking everything inside.

Unless you want to move the files around, I recommend using Git Bash to initialize a repository inside the already created project's folder:

After that, we can go into GHD and open this empty repository under the File tab, with Add local repository.
Simply navigate the local path to the project's base folder.

The repository opens, and GHD automatically stages all the files. I don't know why - we can unstage (untick) all the files for now, we'll be committing them one by one later.

There is one thing here that I want you to notice: The total file count right now is 99.

Before we start staging and committing files, there are some files that we want our repository to ignore.
Inside the base folder, we create a file named .gitignore - this is a special file used by Git repositories specifically for this purpose.

After the file is created, we can write down files that we want ignored. Let's start with the three text files: errors.txt, log.txt and traceback.txt, as they are bound to be very changed often, and there's no reason to keep track of them.

If we switch back to GHD, we can now see the .gitignore file on top. There are currently 97 files: we reached 100 by creating .gitignore, before going back down to 97 by ignoring the three text files.

Let's now take a look at the main portion of the project, the game folder. Not only files, there are some folders inside that need ignoring as well.

The ones we definitely need to include is the cache folder. By finishing the line with a forward-slash, we tell our .gitignore file that it's a folder, and the repository will in turn ignore anything and everything under that folder.
I'll also be including the saves folder. You won't need this unless testing bugs in later stages of the game with multiple people, and even then I don't recommend it - bugs should be replicated, not copied.

As for the gui and tl folders:

  • Including gui means the project will be ready to go for anybody that downloads it. Some may argue that it makes the repository larger in size, and yes it does - but only by about a megabyte, which is completely insignificant
  • tl is the folder containing translations. You might be thinking, "why is there a translation in a new project?" It is for the None language - a way how to change the default texts, anything from "Do you want to Exit?" to "Self-voicing enabled" and inbetween. 
    I recommend including it for regular games, and ignoring it for programming or test projects.

Taking a look at GHD, we see the .gitignore expanded, which ignores some more files, resulting in the file count going further down to 91.

Finally, we can make the repository ignore specific type of files altogether. Asterisk represents "any file name", so for example, *.txt will ignore all text files with the .txt extension.
There are four extensions I always include in the .gitignore of my Ren'Py projects:

  • .rpyc, an optimised version of .rpy files that Ren'Py compiles on project's every launch
  • .rpymc, also a compiled file, but for .rpym - a version of .rpy used for translations
  • .rpyb and .bak, which are both backups for deleted .rpy files

When those are included, we can consider the .gitignore file done, bringing the final file count down to 86.
With that, we can stage the file and commit it. .gitignore committed alone is almost always the initial commit for my projects.

When we have the .gitignore committed, we can continue with a second commit, which groups together everything inside the gui folder. 

At last, there are only the default script files left. Those all make for the third and final initial commit.

And that's all of the default files tracked. Changes tab is now empty and ready for you to start creating, while History shows the three initial commits we've created in this tutorial.

This is how I always prepare my repositories for new Ren'Py Projects. Assuming you'll follow this tutorial, you should be able to do the following:

  • Initialize a repository inside your fresh Ren'Py project
  • Writing a .gitignore file to have your repository ignore files...
  • ...folders...
  • ...and extensions
  • Sensibly commit the default files

Even if there was no programming involved, it was refreshing to work with Ren'Py again. I've written 7 Git tutorials in a row by now (yes, this one wasn't written after Part #4), and honestly, I can't wait to be done with it.

As useful the topic may be, you can't beat working with Screen Language, can you?