Why you can't delete both branches with one command?
Local branch and remote branch have nothing to do with each other, they are different snapshots.
Delete a local branch
You can't delete a branch if you're checked out that branch. You will see this error: Cannot delete branch 'branch-name' checked out at 'some-location'.
To fix this, you will have to switch to a different branch.
After switching, to delete a local branch use the following command:
git branch -d <branch-name>
If the above git command gives you an error The branch 'branch-name' is not fully merged
you can force delete it using -D instead of -d, as below:
git branch -D <branch-name>
-d
is shortcut for —-delete
and it deletes a branch. The branch must be fully merged in its upstream branch, or in HEAD
if no upstream was set with --track
or --set-upstream-to
.-D
is shortcut for --delete --force
Delete a remote branch
git push <remote-name> -d <branch-name>
In most cases <remote-name>
is origin, case in which you'll have something like:
git push origin -d <branch-name>
# Example
git push origin -d release