>_ IzzyLab

Hands-on task

This task is step 1 of the course “Git: first commits”

Create a repository

easy~4 min

The /root/recipes directory holds two recipe files. For now it's an ordinary directory: git knows nothing about it.

Make /root/recipes a git repository. You don't need to commit anything yet — that's the next task. Don't delete or rename the recipe files.

What you'll practise:
  • git
  • git init
  • git status
  • repository

Topic breakdown

Git is a version control system. It keeps a project's history: how files changed, who changed them and why. Any saved version can be brought back.

A repository is an ordinary project directory that has a hidden service directory, .git, inside it. That's where git stores the whole history. You don't need to go in there by hand.

You can create a repository in any directory — even one that already has files in it. The git init command creates .git in the current directory:

cd /srv/blog     # the project directory
git init         # now /srv/blog is a repository
git status       # what git sees in the directory

Git may call the first branch master — that's the old default name; in new projects it's usually called main. For us it makes no difference.

git status is the main command for looking around: which branch you're on, whether there are commits, which files are new or changed. Files git can see but hasn't saved yet are called untracked (Untracked files).

What's checked

  1. /root/recipes is a git repository
  2. No stray repository in /root
  3. Both recipe files are in place

What it looks like