You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Sourcetree本地部分分支消失,无法检出Master分支求助

Hey there, let's work through your Sourcetree branch issues one by one—this stuff can be frustrating, but we’ll get you sorted out!

1. Check if Local Branches Are Hidden or Filtered

First off, Sourcetree’s view settings might be hiding your branches without you realizing it:

  • Open Sourcetree, go to the top menu bar → View → Branch Filter. Make sure options like Hide closed branches aren’t checked, and select Show All Branches to reset the filter.
  • If that doesn’t work, verify the actual state of your local branches via terminal—this bypasses Sourcetree’s UI filters:
    git branch -a
    
    This command lists all local and remote branches. If your missing branches show up here, the issue is definitely Sourcetree’s view filter. If they don’t appear locally, you’ll need to pull them from the remote repo later.
2. Filter 500+ Remote Branches to Find Your Unfinished Work

With hundreds of remote branches, targeted filtering is key. Try these methods:

  • Sort by recent commits: Use this terminal command to list remote branches ordered by their last commit date (most recent first)—your active feature/hotfix branches should float to the top:
    git for-each-ref --sort=-committerdate refs/remotes/ --format='%(committerdate:short) %(refname:short)'
    
  • Filter by branch name keywords: If you remember parts of your branch names (like starting with feature/ or a project-specific term), use grep to narrow things down:
    git branch -a | grep "feature\|hotfix"
    
    For even better precision, search for a specific feature keyword:
    git branch -a | grep "checkout-flow"
    
  • Use Sourcetree’s built-in search: At the top of Sourcetree’s branch list, there’s a search box. Type in keywords (your name, feature module, etc.) to instantly filter matching branches.
3. Fix the "Master Branch Already Exists" Error When Checking Out

This error means your local master branch already exists—it’s just likely hidden in Sourcetree, or you’re using the wrong checkout method:

  • First, confirm the branch exists locally via terminal:
    git checkout master
    
    If this works, go back to step 1 and adjust your Sourcetree view filters to make it visible again.
  • If terminal also throws an error, force-reset your local master to match the remote version:
    git fetch origin
    git checkout -B master origin/master
    
    This command will either create or overwrite your local master branch to sync with the remote origin/master.

内容的提问来源于stack exchange,提问作者Honza

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:28:00