What is Git Init?

Git is a Distributed version control system to track the changes in the source code. Git is free and open-source software. Version Control Systems are software tools for tracking and managing all the kinds of changes made to the source code during the development of the project. It also gives us the power to turn back to the previous version of the source code if by chance any mistake is made out.

What is Distributed Version Control System?

It is a kind of version control system abbreviated as DVCS where the entire version history of the whole codebase is mirrored on every developer’s computer.

How to set up Git?

Firstly, you need to go to your required folder and run the git init command to initialize a new git repository, and then after you can use the git status command to check the files in your Working Tree and in the Staging Area. You cannot see anything below the image coz there is no file in the working tree or staging area.

What is the Staging area in Git?

The staging area is the preview of your next commit. When you create a git commit, Git automatically takes changes that are in the staging area and makes them a new commit. You can add and remove changes from the staging area. But if you add a file let’s say “file.txt” then it is an untracked file and now if you execute git status then it is shown in red color.

If you run the git status command without running git init you will get an error.

How to create an empty Git repository in the specified directory?

For this, use the command: git init <directory>

Running this command will create a new subdirectory called containing nothing but the .git subdirectory.

git init –bare <directory>

The –bare flag creates a repository that doesn’t have a working directory, making it impossible to edit files and commit changes in that repository. You would create a bare repository to git push and git pull from, but never directly commit to it.

git init <directory> –template=<template_directory>

Templates allow you to initialize a new repository with a predefined .git subdirectory. You can configure a template to have default directories and files that will get copied to a new repository’s .git subdirectory.

What is Local Repository?

The Local Repository is everything in your .git directory. Basically, your local repository contains all of your checkpoints and commits.

What is Remote Repository?

Remote repositories are the versions of your project work that are hosted on the Internet or network somewhere around the world.

What is the difference between local and remote repository?

Local repositories reside on the computers of team members. On the contrary, remote repositories are hosted on a server that is accessible to all team members.

git init vs git clone

Both of them has used to initialize a new git repository. However, git clone is dependent on git init. git clone is used to create a copy of an existing repository. Internally, git clone first calls git init to create a new repository, then copies the data from the existing repository.

One thought on “What is Git Init?

Leave a Reply

Your email address will not be published. Required fields are marked *