Last update July 20, 2021 at 10:48
In this section we will find out how to delete a branch git locally and remotely.
If you are in application development you have surely heard of git which is one of the most used versioning tools. In its manipulation I often use branches to create several versions of the source code and test various ideas implementation of a feature. Create a branch git is as easy as ordering
git branch branch_name
ou
git checkout -b branch_name
Instead of branch_name, enter the name of the branch you want to create. Remember that the name of a branch must not contain spaces. Anyway the terminal is your friend. He will take care of reminding you.
As surprising as it may seem, I often forget how to delete a git branch and I think (no, I'm sure) that I'm not alone. That's why today we're going apprendre how to delete a branch git locally and remotely.
Read => 14 of the world's greatest programmers since the dawn of computing
[bctt tweet=”How to delete a git branch locally and remotely – tutorial -2021″ username=”tedidevblog”]
In the rest of the tutorial we will use the term branch_name to designate the name of the branch that interests us.
How to delete a git branch

To delete a git branch locally:
git branch -D branch_name
Lire aussi => How to make a MoonWalk
If you want to delete the branch located on a remote git server, the script is less obvious this time than the previous one. Here's what to type:
git push origin --delete branch_name
Don't make the mistake of adding origin on behalf of your branch as origin / branch. You just need the name of the branch.
Read => Tips for quickly developing an application
Last update July 20, 2021 at 10:48
Conclusion
I was having a hard time deciding if this section was a troubleshooting or rather a tutorial. It doesn't matter now that we know how to remove a git branch from our code whether it's local or remote.
You may be interested in How to easily create shortcut to a file in ubuntu 20.04 LTS et Meaning of the 10 most famous colors in the world - Infographic
