Introduction to git

Table of contents
  1. What is git and why use it
  2. How does it work
  3. How to use it
  4. Everyday workflow

01 What is git and why use it

Git is a version control system, which means it keeps track of changes made to the project. It stores everything that was added to or removed from the file (or files) starting from the very beginning. This lets you safely make changes to the project, knowing you always can come back to the last working version.

Another useful git feature is Branches, which let you make changes to the "copy" of your project, while the original stays intact. This way, while developing a new feature, the original won't be in a state with half-done feature, you will only update it when the feature will be completely finished and confirmed not to break things.

02 How does it work

Imagine a journal, where you make a record each time you spend your money. Then, if you ever want to know how much money you had at a specific moment, you can just replay the records from the beginning, subtracting each transaction from your starting balance.

This journal is essentially Git, and a record you add to it called Commit. A Commit is a building block of git, its a record about some change. After you make a change to your project you need commit it, letting git know that something was changed. You should commit your changes regularly. Using the journal analogy, it wouldn't really help if you added a balance change once a week , as you wouldn't be able to tell how much money you spend each day. Also, if for some reason a small part of your big commit is broken and you need to reverse it, you will reverse the whole commit, even though only a small part of it doesn't work. To avoid such situations, a commit should be about one specific thing that changed.

03 How to use it

You "talk" to Git writing commands in the terminal. While there are a lot of different git commands for all kinds of situations, here are some most used ones:

Now say we have some changes and we want to commit them. First of all we need to let git know which changes we want to commit. We can do this by using:

04 Everyday workflow

  1. Before doing any changes, 'git pull'click to copy to download latest version from cloud
  2. Then set active branch to your own branch with 'git checkout art-brnch'click to copy (first time you will write this with -b to create a branch)
  3. Say today you want to make a camp scene. You start making it, making commits along the way with 'git add .'click to copy and commits like this:
    git commit -m "first version of the camp scene"click to copy git commit -m "improve fire animation in camp"click to copy git commit -m "add place to sleep in camp"click to copy
  4. After you done working for today, you push your changes to the cloud 'git push origin art-brnch'click to copy
  5. After a couple of days when you mainly done making the scene we together merge changes from your branch to the master branch (a.k.a to the original)
NOTE: Git and Godot scenes doesn't work well together when changes are made to the same scene by two different people, so we should be mindful about that