fbpx

How to delete a Git branch locally and remotely?

In order to delete a Git branch locally and remotely, you need to run the following commands:

Delete a Git branch Locally

You can use -D instead of -d to force the branch deletion without checking the merged status.

git branch -d <branch_name>

For example, if you would like to remove the topic/wip branch locally, run the following command:

git branch -d topic/wip

Delete a Git branch remotely

git push <remote_name> --delete <branch_name>

For example, if you would like to remove a branch called topic/wip from the remote called origin, use the command below:

git push origin --delete topic/wip

Leave a Reply

Your email address will not be published. Required fields are marked *