letter Q
letter Q

Reputation: 15405

How to delete local and remote branch using git

So right now these are the branches I have:

WalnutiQ> git branch -a
* develop
  feature-model_in_javascript
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/develop
  remotes/origin/feature-model_in_javascript
  remotes/origin/master

My goal is to delete the branch feature-model_in_javascript so I tried:

WalnutiQ> git branch -d feature-model_in_javascript
Deleted branch feature-model_in_javascript (was 4604f04).

So now when I check my branchs I get:

WalnutiQ> git branch -a 
* develop
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/develop
  remotes/origin/feature-model_in_javascript # <== HOW DO I DELETE THIS????
  remotes/origin/master

How do I delete that remote branch? I manually deleted it by clicking the delete button on https://github.com/WalnutiQ/WalnutiQ/branches

Upvotes: 2

Views: 465

Answers (3)

Tormod Hystad
Tormod Hystad

Reputation: 2405

A slightly more modern syntax for deleting remote branches (perhaps easier to remember) is:

git push origin --delete <branchName>

Upvotes: 1

Nancy
Nancy

Reputation: 1293

Just use below to delete the remote branch:

git push origin :<branch>

remove remote tags is the same.

You can find details here: http://git-scm.com/book/en/Git-Branching-Remote-Branches

Upvotes: 1

Greg Hewgill
Greg Hewgill

Reputation: 994281

If you have already manually deleted the branch on the upstream server, then use

git fetch -p

to "prune" your remote tracking branches. Any branches under remotes/origin that no longer exist on the server will be deleted from your local repository.

Upvotes: 6

Related Questions