Git Tutorial
Git
Git is a version control system that tracks changes to files over time.
Why Git? Because Git is good, it’s right, it’s free.
The environment where versions are managed is the repository. A Git repository is the .git/ folder inside a project. This repository keeps track of all changes made to the project files, building a version history over time. In other words, if you delete the .git/ folder, you delete the project’s local history (game over).
Stage & Commit
Sooner or later, you’ll feel ready to add your progress to the repository. To do this, first you stage the files, and then you commit — that is, you create a new version of the files you selected.
To make a commit, you need to comment it — meaning you write a short descriptive sentence about the changes you made to the files/scripts/folders you’re committing.
Git tracks all changes made to the files, but it won’t save them in your local version until you stage and commit them.
GitHub
Repositories
From the website, you can view your own repositories and those you’ve been invited to collaborate on.
A repository
GitHub Account
At this point, you’ve signed up with a GitHub account. Among the many users, you might come across the divine TorTar — don’t worry, his are just digital hammer blows.
Download & Install Git
From the Git website homepage, download the latest version:
If you have a Mac, throw it away.
If you still have a Mac after throwing it away, follow the instructions on the site.
If you were thinking of a BigMac, follow me.
Configuration
Open the command prompt (press the Windows key → type “cmd” → press ENTER).
Run the following two lines of code:
git config --global user.name "username used on github"
git config --global user.email "email used on github"
You’ve just linked your information to all future commits you’ll make from your computer.
You can verify the configuration with the command:
git config user.name
Basic Git Commands
Dal pull al push, passando per lo stage e il commit.
For the laziest
There is a GitHub desktop app to manage your repositories without using the command prompt — especially useful if you don’t use an IDE to program.
It saves you a few lines of code if you’re a devoted user of the laser mouse.
IDE and Git
Git is integrated into the most widely used IDEs — for example, RStudio (for the statistician who never has to ask), and Visual Studio Code (for those hunting pythons — and other creatures).
In both cases, if you’ve understood the Git workflow — from staging to commit, from push to pull — you’ll feel right at home and only need to write the commit message.
Only by popular demand, tutorials on how to initialize and use Git in both IDEs will follow.