ILILCode
HomeGitFoundations

Setup and your first repository

Check the install, set your identity once, then turn any folder into a Git repository.

Lesson 2 of 9 in Git8 min1 exercise

First, check that Git is installed. Anything above version 2 is fine — the commands in this topic have not changed in years.

Check, then introduce yourself
git --version
# git version 2.43.0

git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global init.defaultBranch main

Every commit records an author. The --global flag writes those values to ~/.gitconfig once, so you never repeat them. The last line makes main the default branch name instead of master.

Turn a folder into a repository

cd ~/projects/notes
git init

# Initialized empty Git repository in ~/projects/notes/.git/
git status
# On branch main
# No commits yet

git init creates the hidden .git folder. Your existing files are untouched and still untracked — Git only starts recording what you add and commit.

Exercises

Checked in your browser · hints and solutions included

01

Exercise

Start a repository

You are in a new project folder that is not under version control yet. Turn it into a Git repository.

terminal