Photo by Roman Synkevych πΊπ¦ on Unsplash
Discover the Magic of Git Branches: How to Make Your Code Work Like a Wizard!
Table of contents
What are git branches
Consider git provides you with a line of development, Branches are a separate line of development within the git repository. Each branch has its own changes & modification & these changes do not effect other branches within the same repository .
Use of branches unable multiple developer working on the same codebase simultaneously as well as manage code base, bugs & fixes , features & vulnerability patchs.
when you create a git repository following things happen :
The default branch is created by the name of main/master
developers create multiple branches as per the need
when a new branch is created it is a copy of the code from the branch it was created.
any changes made to perticular branch will only affect the new branch and will not affect master branch
branches are merged back to the main branch once code is completed
The main branch is considerd as stable/production and the changes should only be added to stable branch
Summary: Git branches allow for multiple lines of development within a single repository. Each branch has its own unique changes and modifications, and changes made to one branch do not affect others. This allows for multiple developers to work on the same codebase, manage bugs, fixes, and patches. The default branch is typically called main or master, and new branches are created as needed, starting as a copy of the original code. Branches are merged back to the main branch when the code is complete, and the main branch is considered stable and used for production.
to learn git branching without doing with real projects so you can get gist of it:
clickt the link above