How to Delete a Git Branch (Locally and Remotely)
Deleting a Git Branch Remotely
remote_name
: the name of the remote repository you're interacting with. If you don't remember changing this, it's most like justorigin
branch_name
: the name of the remote branch you'd like to delete
Common Errors
Branch Doesn't Exist on the Remote
Here are some troubleshooting steps you can try:
Make sure you're in the correct git directory on your machine
Make sure the branch you're trying to delete actually exists. Run
git branch -r
to list all of the remote git branches belonging to your repo.Make sure the branch you're trying to delete exists in the remote repository you provided. Run
git branch -r
to get a list of all the remote repos and their branches.
Remote Repository Doesn't Exist
Here are some troubleshooting steps you can try:
Make sure you're in the correct git directory on your machine
Make sure the remote repository you're providing actually exists. You can run
git remote -v
to list all of the remote remote repositories associated to your repo
Deleting a Git Branch Locally
branch_name
: the name of the local git branch you'd like to delete
Common Errors
Branch Not Found
Here are some troublshooting steps you can try:
Make sure you;re in the correct git directory on your machine
Make sure the branch you're trying to delete actually exists. Run
git branch
to list all of the git branches you have stored locally