What is the command to delete a branch in git?
Answers
Answer:
First, we print out all the branches (local as well as remote), using the git branch command with -a (all) flag. To delete the local branch, just run the git branch command again, this time with the -d (delete) flag, followed by the name of the branch you want to delete ( test branch in this case).
Deleting Branch in Git
Git is a highly efficient Version Control System (VCS). It helps in maintaining a record of the changes made to files.
We save the files in git by what is known as a commit. A commit just saves the changes made to the file and assigns to the change a commit message. The commit message must describe why a particular change was made.
Branches are a powerful feature of Git. We can create a branch and work on planned changes without affecting the code in production. When the planned upgrade is tested and is stable, we can then merge this branch into the main branch.
Branches also let multiple types of changes to be done by different teams. Teams can work on multiple features on multiple branches simultaneously and later merge the branches.
The command to create a branch is
The command to switch to a specific branch is
Finally, The command to delete a branch is
For example, if the branchname is test, the command is:
A screenshot is attached for reference. The just lists out all the branches.