

There are some of the best practices we should follow while naming branches:ġ. Here, we can provide the name of the branch we want to checkout. To switch between different branches of the repository, we can use the command: git checkout The above command will show all the local branches in a repository, along with the * symbol marked in front of the name of the branch we are currently on. If you want to display the total branches in a repository, then you can use the command: git branch When you want to work on a new feature, you create a branch diverging from the main branch using the command git branch new_branch_name. To create a branch in git, we can use the command: git branch
#Create branch code
Branching also helps in maintaining the stability of the code base. In this way, the development of bug fixes will also be facilitated, and there will be fewer errors as it’s easier to maintain a portion of your work than having large branches having all the code. Branching can be helpful in many terms firstly, we can work on any specific feature in an isolated manner without disturbing the work on the main branch.

Any repository can have as many branches, each having a different version of the repository. In git, each branch is a version of any repository, or we can call it the independent line of development. Use to push the committed changes to the main/master branch of the remote repository.īranching is a concept in git which allows us to diverge from the main branch and continue to work in an isolated manner without messing with the main branch.

Use to show the current status of the working directory and the staging area Use to commit the staged changes to the remote git repository Use to add untracked files to the staging area Use to create a local, new git repository
