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.
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.
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:
'git init'click to copy
Creates a Git repository (note: 'git clone'click to copy creates repository automatically). Without creating a repository inside a folder with your project you won't be able to use any other Git commands.
'git status'click to copy
Information about current state of a repository. Among other things it will show all uncommitted changes.
'git checkout branch_name'click to copy
Change active branch. You can't change branches if you have uncommitted changes. To create and change the branch in the same time, add "-b" before branch name: 'git checkout -b new_branch_name'click to copy
'git pull'click to copy
Download the latest version from cloud. Latest version will always change because i will make changes to it from my computer.
'git push origin name_of_branch'click to copy
Send your changes to the cloud (a.k.a update the latest version).
'git branch'click to copy
See which branch now set as active.
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:
'git add filename_that_changed'click to copy
If you want to commit all changes you have made (to different files) you can use: 'git add .'click to copy — dot essentially means 'everything'.
Now that git knows which changes we want to commit, commit them by using:
'git commit -m "commit message here, a couple of words about what changed"'click to copy
This commits changes to the active branch.
'git pull'click to copy to download latest version from cloud'git checkout art-brnch'click to copy (first time you will write this with -b to create a branch)'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
'git push origin art-brnch'click to copy