5

Usually, when I send Pull Requests on github, I would create a branch, make my changes, then ask them to merge that branch into their repo.

Once that is done, on Github, I delete the branch (but github just hides it). I then permanently delete the branch on the Github site.

Now that the remote branch is gone, how I can synchronize my local repo with the remote? I have tried fetching and pulling, but that does not delete the branches in my local repo.

Will I have to manually delete them from my repo, or is there some way to sync it?

F21
  • 32,163
  • 26
  • 99
  • 170

2 Answers2

1

You can try a:

git remote prune origin

(assuming the remote 'origin' references your GitHub repo)

This is explained in "cleaning up old remote git branches" (git branch -d localbranch)

I don't know of a native git command which would do both.
Only a script like "git_remote_branch" would delete a branch both on GitHub and locally

delete (aliases: destroy, kill, remove, rm)

Delete the remote branch then delete the local branch.
The local branch is not deleted if there are pending changes.

$ grb delete branch_name [origin_server]
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • That stopped all those branches from showing up on `origin` when I run `git branch -a`, but the branches still exists in my local repo. – F21 Apr 19 '13 at 06:39
  • @F21 true. I have edited my question to make this limitation more visible, and to suggest a possible solution. – VonC Apr 19 '13 at 07:55
0

Another option to clear (on your local) deleted branches on the server could be

git fetch –p

Hope this helps.

4u.Ans
  • 1,279
  • 14
  • 22