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!
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:
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.git branch -a
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), usegrepto narrow things down:
For even better precision, search for a specific feature keyword:git branch -a | grep "feature\|hotfix"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:
If this works, go back to step 1 and adjust your Sourcetree view filters to make it visible again.git checkout master - If terminal also throws an error, force-reset your local
masterto match the remote version:
This command will either create or overwrite your localgit fetch origin git checkout -B master origin/mastermasterbranch to sync with the remoteorigin/master.
内容的提问来源于stack exchange,提问作者Honza
相关产品推荐
相关产品推荐

