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?

2 Answers 2

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] 
Sign up to request clarification or add additional context in comments.

2 Comments

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 true. I have edited my question to make this limitation more visible, and to suggest a possible solution.
0

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

git fetch –p

Hope this helps.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.