1. Setup and Configuration : config, clone, init

1. Setup and Configuration : config, clone, init

  1. Configuring your GIT:

Before getting into configuration, check the version of git available in your system, if not install GIT.

You can check the version using:

git --version

As, we have installed GIT, in your system open git bash

Git Bash is a command-line interface (CLI) tool for Windows that enables users to use Git commands and a variety of Unix-style shell utilities. It is a key part of the Git for Windows package and provides a convenient environment for working with Git repositories.

To set the configuration, enter the following command

git config --global user.name "username"
git config --global user.email "username@gmail.com"
  1. Clone a Repository into your code editor

To clone a repository means, we access the files and the code which is already created in the GITHUB website in our code editor (e.g. VS CODE)

kindly create a account in GITHUB

To clone a repository, open your terminal in your code editor and run the following command

git clone <link of the repository as HTTPS from GITHUB>
  1. init command in GIT

The git init command is used to initialize a new Git repository in your project.

git init

we create a empty repository in GITHUB and we interconnect them using the below command

git remote add origin <link of the repository as HTTPS from GITHUB>

Then we verify, if the created repository is remote

git remote -v

We need to check the branch of the project which we have created in our code editor, this will show the branch as “master” initially.

git branch

We need to change the branch name into “main”

git branch -M main

Finally, we need to push our initialized project into GITHUB

git push origin main

After all of this, the project has been initialized and we can add files and proceed with the project.

when to use git init:

  • Starting a new project from scratch and you want to use Git for version control.

  • Converting an existing project folder into a Git repository.