Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Creating a Repository | Introduction to Git
Git Essentials
course content

Conteúdo do Curso

Git Essentials

Git Essentials

1. Introduction to Git
2. More Advanced Interaction
3. Undoing Changes
4. Working with Branches in Git

bookCreating a Repository

What is a Repository?

A Git repository, often referred to as a "repo," is a storage location for your project's files, as well as the entire history of changes made to those files.

This comprehensive history allows you to track, manage, and collaborate on your project effectively. When you create a repository, Git starts allowing you to track changes in files you choose to monitor, enabling you to review, revert, or merge those changes easily.

Git repositories can either be created from scratch locally or you can make a copy of an existing repository, however, we'll cover remote repositories later in another course. Now, let’s focus on creating a local repository.

Creating a Local Repository

To create a Git repository for your project, follow these simple steps:

Step 1: Create Your Project Directory

We’ll use the mkdir (make directory) command to create an empty directory:

Here, name_of_directory is the name of the directory we want to create. Let’s call our project directory "GitEssentials":

Step 2: Navigate to Your Project Directory

Before we can create a Git repository, we need to be in the directory where our project files are located. We’ll use the cd command to navigate to our project's root directory. This command looks as follows:

We’ll replace /path/to/your/project with the actual path to our project directory:

Step 3: Initialize a Git Repository

Once we’re inside our project directory, we’ll use the git init command to initialize a Git repository:

Let's take a look at an example:

If you encounter a similar hint, you can simply ignore it for now. Pay attention to the following message:

Initialized empty Git repository in /Users/sidak.kryryl/GitEssentials/.git/

As you can see, the git init command creates a hidden directory called .git in your project folder. It contains all the necessary files and data that Git needs to manage your project. We’ll discuss this directory in more detail in the following chapters.

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 4
We're sorry to hear that something went wrong. What happened?
some-alt