Skip to content

Introduction

gitconfig

In this section, you will learn how to set up a Git repository and initialize it for a new or an existing project. The points of this section will cover generating a new Git repository or initializing an existing one, copying an existing repository into a new directory, configuring a Git repository for remote collaboration, and creating short commands that map to longer ones. The commands are described below. Find detailed information about the following commands on our next pages.

git init

The git init command is used to generate a new, empty Git repository or to initialize an existing one. With the help of this command a .git subdirectory is created, which includes the metadata, like subdirectories for objects and template files, needed for generating a new Git repository. The simplest use of git init is to set up version-controlled projects, as there is no need to manually create the .git directory or input files.

bash
git init

git clone

The git clone command is used to create a copy of an existing repository into a new directory. Also, it is used to create remote-tracking branches for each branch in the cloned repository. It is one of the most common commands allowing users to obtain a development copy of an existing central repository.

bash
git clone <repository-url>

git config

The git config command sets configuration variables. It controls Git's look and operation. This command accepts arguments for specifying the configuration level (system, global, or local). It is primarily used to set, get, or delete configuration variables.

bash
git config --global user.name "Your Name"
git config --global user.email "[email protected]"

git alias

A git alias is a shortcut that maps shorter commands to longer ones. There is no direct git alias command; aliases are created using the git config command and configuration files. They can be set in a local or global scope alongside other configuration values.

bash
git config --global alias.co commit

Practice

What are the purposes of different Git commands?

Dual-run preview — compare with live Symfony routes.