GIT- Every developer’s best friend
Part-3
Git’s graph model
A graph is a way to model connections and consists of edges and nodes.
Types of graphs:
- Directed Graph: Nodes are connected in a particular direction.
2. Acyclic Graph: Graphs having no cycles.
3. Directed Acyclic Graph: Nodes are connected in a particular direction with no cycles within the graph.
Branches
A branch occurs if a commit has more than one child.
In the above graph, we can see that there are 2 new branches 1 & 2 carrying new commits.
Types of Branches :
- Topic branches: A feature, bug fix, configuration change.
- 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 branchgit 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 :)