New! Explore our Programming Academy and AI Tutor - learn to code from scratch, free to start. Explore Now
Programming› Git› Your First Repository

Your First Repository

💻 Git

Install Git, configure your identity and create a repository.

Lesson 2 of 9 Tutorial
0 of 9 completed

Every Git project starts with a repository and a configured identity. Do this once and every commit will carry the right name and email.

By the end of this lesson you can:
  • Configure user.name and user.email.
  • Create a repository with git init.
  • Understand the default branch name.

Configure Your Identity

Git stamps every commit with a name and email. Set them globally once.

git config --global user.name "Ada Obi"
git config --global user.email "ada@example.com"
git config --global init.defaultBranch main

git config --list

Create a Repository

Run git init inside the project folder. Git creates a .git directory and begins tracking.

mkdir my-project
cd my-project
git init

Check Status

git status is the command you will run most. It tells you which files are untracked, modified or staged.

git status
Warning Do not create a repository inside another repository by accident. Check for a parent .git folder if git status looks noisy.

Practice

  1. Configure your name and email for Git.
  2. Create a folder, initialise a repository and run git status.
  3. Explain the difference between an untracked and a modified file.

Hands-on exercise

In a new folder:
1. Initialise Git.
2. Create a file called README.md with one line.
3. Run git status and read the output.
4. Stage the file and run git status again.

Recap

Configure your identity once, initialise a repository per project and use git status to see what Git knows.

Example

git config --global user.name "Ada Obi"
git config --global user.email "ada@example.com"
git config --global init.defaultBranch main

git config --list

Exercises

Exercise 1. Initialise a project Easy
In a new folder:
1. Initialise Git.
2. Create a file called README.md with one line.
3. Run git status and read the output.
4. Stage the file and run git status again.
Git exercise-1.txt
Expected Output
README.md moves from untracked to staged.

Lesson Nav

Lesson sections