GIT- Every developer’s best friend

Hershil Piplani
2 min readDec 12, 2021

--

Part-3

Git’s graph model

A graph is a way to model connections and consists of edges and nodes.

Types of graphs:

  1. Directed Graph: Nodes are connected in a particular direction.
Directed Graph

2. Acyclic Graph: Graphs having no cycles.

3. Directed Acyclic Graph: Nodes are connected in a particular direction with no cycles within the graph.

Directed Acyclic Graph

Branches

A branch occurs if a commit has more than one child.

Source: Medium

In the above graph, we can see that there are 2 new branches 1 & 2 carrying new commits.

Types of Branches :

  1. Topic branches: A feature, bug fix, configuration change.
  2. Long-lived branches: master branch, develop are some examples of long-lived branches.

Creating branches:

Command:

git branch <branch_name>

To change the branch

git checkout <branch_name>

A shortcut way to create as well as change the branch is using the “-b” flag

git checkout -b <branch_name>
# -b flag creates and chekouts the branch

Deleting branches

Command

git branch -d <branch_name>
#-d flag is used to delete a branch
git branch -D <branch_name>
#This will delete the branch but the commit associated to that branch will not be deleted. That commit is stored as garbadge value.
This is called as dangling.

Check the history of all the branches

git reflog

Stay tuned for the next part:) and also

Please support me by following me and also am open to suggestions on how I can improve so please feel free to leave a comment :)

--

--

Hershil Piplani
Hershil Piplani

Written by Hershil Piplani

An inquisitive person trying to create a measurable impact on the ecosystem through technology. Fan of oss and arsenal. 👉 https://github.com/herkura