Forrest logo
back to the git tool

git:warp:fe5a7

Delete local and remote git branch
$ git push -d ${remote_name} ${branch_name}
$ git branch -d ${branch_name}
try on your machine

The command git push -d ${remote_name} ${branch_name} is used to delete a branch on a remote repository.

Here is a breakdown of the command:

  • git push: This is the command to push changes from a local repository to a remote repository.
  • -d: It is an option for delete. It tells Git that you want to delete a branch on the remote repository.
  • ${remote_name}: This is the name of the remote repository where the branch exists.
  • ${branch_name}: This is the name of the branch you want to delete on the remote repository.

So by running git push -d ${remote_name} ${branch_name}, you can delete the specified branch on the remote repository.

On the other hand, the command git branch -d ${branch_name} is used to delete a branch on the local repository.

Here is a breakdown of this command:

  • git branch: This is the command to manage branches in Git.
  • -d: It is an option for delete. It tells Git that you want to delete a branch on the local repository.
  • ${branch_name}: This is the name of the branch you want to delete on the local repository.

So when you run git branch -d ${branch_name}, it deletes the specified branch on the local repository.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the git tool