Basic Crash Course of Git Command

Written by omanjali

Basic Crash Course of Git 

A version control system Git is a version. You can track code changes with Git. To collaborate on code, utilise Git.

Features of Git

Git is used in tracking coding alterations ,Keeping track of who made modifications and collaborating with code

Types of VCS:

  • Centralized version control system (CVCS).
  • Distributed/Decentralized version control system (DVCS)

Advantage of Git:

1.Git is a free open Source:Git is available over the internet. If you search git ,you will get freely because it is free and open Source.

2.It is very fast and occuply less space:The most important things about git is it is very fast and when you perform then every operation requires communication with a remote server.

3.Implicit backup:Here chance of lossing data is very rare because we have multiple repositories here

4.Security:Without knowledge of Git, it is difficult to update any data from the Git database, including a file’s name, date, commit message, and others.

Difference between Centralized version control system and Distributed/Decentralized version control system (DVCS):

A central server is used by the centralised version control system (CVCS) which used to store all files and allow for team collaboration. However, CVCS’s single point of failure, or failure of the central server, is a disadvantage. Unfortunately, if the main server is offline for an hour, no one can collaborate at all at that time. The entire project history will be lost if the central server’s disc becomes corrupted and a thorough backup has not been made.

DVCS clients completely mirror the repository in addition to checking out the most recent snapshot of the directory. Any client’s repository can be copied back to the server to recover it if the server crashes. The repository is completely backed up with each checkout. Git doesn’t rely on a centralised server, thus you can carry out a lot of actions even when you are offline. When you are offline, you can still commit changes, make branches, read logs, and conduct other actions. Only publishing and consuming the most recent changes require a network connection.


Consider that you changed two files, sort.c and search.c, and that you want two separate commits for each action. You are able to commit after adding one file to the staging area. Repeat the process for a different file after the initial commit.

1.First commit
$ git add sort.c
2.A file is added to the staging area
$ git commit –m “Added sort operation”

3.Second commit

$ git add search.c

4.Staging area by adding a file

$ git commit –m “Added search operation”


How to Install Git ?

If you are using Linux then use the below command:

1.$ sudo apt-get install git-core

Enter the password:

2.Now , if you need to check git version

$ git –version

Response:git version

Step by Step the workflow of git

1.Clone the git repository .
2.You can add the files.
3.You can update the files also by taking other changes.
4.Before commit ,you can revew the changes.
5.Once you review and did commit then, you can push the command to the repository.
6.After push , if you find some mistake from your side then you can make correct the last changes and again push the code to the repository.

Git Command

1.Clone Operation

If you want to clone the repository in your local system then create a new directory  and then performs  clone operation

$ mkdir name_any

$ cd name_any
$ git clone


Know More About Git :Git Command

2. Git init

An empty Git repository can be created with the git init command.
A.git folder with a few subdirectories is generated in the directory once the git init command is run. Other files are created after the repository has been started.

$ git init

3.Git add

After determining the files’ state, the add command is used to add the files to the staging area.
The “git add” command is used to add any new or updated files before executing the commit command.

$ git add.

4.git commit

Assuring that the modifications are saved to the local repository is the commit command.
You may explain everything to everyone and make sure they understand what has happened by using the command “git commit -m message>”.


5.Check Status

The repository’s current status can be found using the git status command.The git status will indicate if the files are in the staging area but have not yet been committed. Additionally, it will display the message no modifications to commit, working directory clean if there have been no changes.If yo want to check the status of the code which you have clone or added/edit

$ git status

He switches the function’s return type from int to size t. He runs the git diff command to review his modifications after testing the code.

$git diff

The and are initially set up using the git config command. This details the login and email address that will be utilised from a local repository.

6.git config

Initially, the and are set up using the git config command. This indicates which login and email address from a local repository will be used.
Git Configuration writes the settings to all of the computer’s repositories when the —global flag is used.

$ git config –global <email id>

7.git branch

The branch the local repository is on can be found with the git branch command.
The command allows for the addition and deletion of branches.

$   git branch <branch_name>

8.git merge

The command combines the adjustments made to each branch.
It is applied to the stable branch to combine the modifications from the staging branch.

  $ git merge <branch_name>

9.git pull

Changes from the remote repository are fetched and merged into the local repository using the git pull command.
Git pull origin master replicates all of the files from the remote repository’s master branch to the local repository.

$ git pull <branch_name> <remote URL>

10.git push

When pushing content from the local repository to the remote repository, the git push command is used.
The command is used after modifying a local repository and sharing the changes with the remote team members.

$ git push -u origin master


Read More:How to install Ubantu

About the author


Leave a Comment