git-delete-branch:tldr:cc31b
git-delete-branch: Delete a local and remote Git branch.
$ git delete-branch ${branch_name}
try on your machine
The command git delete-branch ${branch_name}
is not a built-in Git command. Git does not have a direct delete-branch
command. However, you can achieve the same result using the git branch -d
or git branch -D
command.
Here's the explanation for both of these commands:
-
git branch -d ${branch_name}
:- This command is used to delete a Git branch with the name
${branch_name}
. The branch deletion is only performed if the branch has been fully merged with the current branch. If any commits in the branch have not been merged yet, Git will prevent the deletion to avoid losing any data. - It is a safer option as it enforces the merge condition.
- Usage example:
git branch -d feature-branch
- This command is used to delete a Git branch with the name
-
git branch -D ${branch_name}
:- This command is used to forcefully delete a Git branch with the name
${branch_name}
. Unlike the previous command, it does not check if the branch is fully merged or not. It deletes the branch regardless of its merged status. - It is a more aggressive option and should be used with caution to avoid potential data loss.
- Usage example:
git branch -D feature-branch
- This command is used to forcefully delete a Git branch with the name
In both cases, remember to replace ${branch_name}
with the actual name of the branch you want to delete.
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.