Search code examples
version-controlatlassian-sourcetree

Sourcetree caches old branches that no longer exist on github. I do not want this


(Sourcetree on Mac)

This has happened for years at multiple companies. I can't imagine it's something I'm doing wrong (or right), so perhaps it's a feature.

My coworker develops and pushes some code. I see the branch under Remotes in Sourcetree. She creates a PR. I merge it and delete the branch on github.com. I go back to Sourcetree and I still see the branch listed under Remotes. Weeks later it is still there. There are 2 things I can do:

  • Delete the branch & push the deletion
  • I, unsurprisingly, get "error: unable to delete 'branchA': remote ref does not exist"

or

  • I can check out the branch!
  • I check it out with no problem, and when I commit and push to origin it "remembers" the history of branch as if it was always there, it's not as if I created a new branch with the same name

Is this supposed to happen? There is an option "Keep backups on destructive operations" in the Sourcetree Settings. Maybe it's a feature?


Solution

  • I don't think this is supposed to happen. Unfortunately, the only thing that works for me is to remove the remote repo and add it again. That way, it clears the cached branches.