Git
Tutorial: install Git and make your first commit
Install Git on your computer and save the first 'checkpoint' of your project.
You already know what Git is in theory (check the "Git and GitHub for beginners" article if not). Today you're actually going to install it and make your first commit, no drama.
Step 1: install Git
- Windows: download the installer from git-scm.com and follow the wizard (click "Next" on everything if you're unsure, the defaults are fine).
- macOS: open the terminal and run
git --version. If it's not installed, macOS will offer to install it automatically. - Linux:
sudo apt install git(Ubuntu/Debian) or your distro's package manager.
Step 2: introduce yourself to Git
git config --global user.name "Your Name"
git config --global user.email "you@email.com"
Git needs to know who you are to sign your commits. It's not a bureaucratic form, it's a setting you configure once per computer.
Step 3: initialize a repository
mkdir my-project
cd my-project
git init
git init turns that folder into a repository: from now on, Git can track the history of everything that happens inside it.
Step 4: make your first commit
echo "# My Project" > README.md
git add README.md
git commit -m "First commit: add README"
You just created your first official "checkpoint". If something goes wrong later, you can always come back to this exact moment. It's, literally, an undo button with superpowers and a perfect memory.
Step 5: check the history
git log
You'll see your commit, with your name, your email, the date, and the message you wrote. Every future commit will stack up here, telling your project's complete story.
What did you just learn?
- How to install Git and configure your identity.
- How to initialize a repository with
git init. - How to make your first commit with
git addandgit commit.