Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags


How to create a local GIT repository in Linux

Umme Ammara

Git is a distributed version control system that can track changes to directories of files. Once you have installed the git version control and setup git install configuration, you can create a local git repository in Linux by following the steps given below:

Step 1

We need to verify that git is actually installed in the system. For this, run the following command in the terminal:

rpm -q git

The rpm is a default open source management utility tool that allows the users to install, update, update, and verify system software.

An important step at this stage is verifying that the global parameters have been set. We can verify this by looking inside the .gitconfig file. Run the following command:

 git config --global --list

Once the list is displayed, make sure that the correct user name and email are set.

Step 2

In the home directory, create a directory named ‘git’ that will contain all git projects. We can create a directory using the following command:

mkdir git
cd git

The mkdir command creates a directory in the current location, and cd changes the current working directory in Linux.

Once done, you can display the path of this new directory by typing the following in the terminal:


Step 3

Once we have created a directory, we can create a directory for the repository within it. Suppose the name of the repository is local_repo. We will create the directory as shown below:

mkdir local_repo
cd local_repo/

Once done, you can display the path of this new directory by typing the following in the terminal:


Step 4

Now we can create the git repository by executing the following command:

git init

One should execute the git init command from within the directory. This command creates a .git directory that contains all the version control information.

Step 5

The final step is to check the status of the git repository by running the following command in the terminal:

git status




Umme Ammara
Copyright ©2022 Educative, Inc. All rights reserved

View all Courses

Keep Exploring