How do you delete a remote Git branch?

GitKraken
2 min readDec 4, 2020

--

Before you get into deleting remote branches in Git, we recommend you familiarize yourself with how to delete local branches.

Deleting a remote branch works a bit differently than deleting a branch locally in Git.

If you run the git branch -d command associated with a remote branch, Git will tell you the branch is not found.

You actually won’t be using the git branch command to delete a remote branch. Instead, you will be using the git push command.

Next, you will need to tell Git which remote repository you want to work with, followed by the — delete flag, followed by the branch name.

It should look something like this:

$ git push <name-of-remote-repository> --delete <branch-name>

How do you find a list of your remote branches in Git?

If you don’t have the visual benefit of the GitKraken Git client which displays your remote branches, you will need to run git branch -r to get a list of the remote branches in your Git repository.

Want to make working with remote branches in Git easier? Download the GitKraken Git GUI for free.

Additional Learning Git Resources: Git Branch Tutorial

Originally published at https://www.gitkraken.com.

--

--

GitKraken
GitKraken

Written by GitKraken

Creators of the world's most powerful suite of Git tools: GitKraken Client, GitKraken CLI, Git Integration for Jira, GitLens for VS Code & IntelliJ (soon).

No responses yet