Git – How to Delete Local and Remote Branch

git

Deprecated: get_the_author_email is deprecated since version 2.8.0! Use get_the_author_meta('email') instead. in /home/cloudber/public_html/wp-includes/functions.php on line 4713

Delete a local branch

A local branch is a branch which is the one inside the computer.

To delete a local branch, execute following git command. Replace the branch_name with the one that you want to remove in your local computer.


git branch -d branch_name

To force delete a local branch, replace -d with -D, a capital d in the same command as above.


git branch -D local_branch_name

Delete a remote branch

A remote branch is a branch which resides in a remote repository, such as Bitbucket, GitLab, GitHub and so on.

To delete a local branch, execute following git command. Replace the origin with the one that you want to remove in your local computer.


git push origin --delete branch_name

In most cases, a remote_name is origin. To see a list of remote branch. Use the following command.

git branch -r

Author: Wu Chia Chong

My main areas of interest are software architectures and software design methods, patterns, and new trends in software development.

Author: Wu Chia Chong

My main areas of interest are software architectures and software design methods, patterns, and new trends in software development.