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

如何在Mercurial版SourceTree中检出分支与旧提交?

Checking Out Branches and Old Commits in Mercurial via SourceTree

Hey there! Great question—Mercurial absolutely supports checking out old commits (and branches) to view their file states, just like Git does, though the terminology and GUI steps in SourceTree have a few small differences from Git. Let me walk you through exactly how to do this:

Checking Out a Branch

  • Open your Mercurial repository in SourceTree.
  • Look to the left-hand panel and find the Branches section.
  • Right-click on the branch you want to switch to, then select Checkout [Branch Name] (some versions might label this Update to [Branch Name]—they’re the same action under the hood).
  • Confirm the action if prompted, and SourceTree will update your working directory to match the latest state of that branch.

Checking Out an Old Commit

  • Navigate to the commit history panel in SourceTree (this is the main timeline view showing all your commits).
  • Locate the specific old commit you want to inspect—you can search by commit message, hash, or date to find it faster.
  • Right-click on the commit, then choose Update to revision—this is Mercurial’s equivalent of Git’s "checkout old commit" action.
  • In the pop-up dialog, verify that you’re selecting the correct revision hash, then click OK.
  • Your working directory will now reflect the exact file state as it was at that commit.

Important Notes

  • If you have uncommitted changes in your working directory, SourceTree will warn you before switching. You’ll need to either commit the changes, Shelve them (Mercurial’s version of Git’s stash), or discard them to proceed—this prevents accidental data loss.
  • When you’re on an old commit (what Git calls a "detached HEAD" state), Mercurial treats this as an anonymous branch. If you want to make changes based on this commit, be sure to create a new named branch first (right-click the commit and select Branch from revision)—otherwise, your new commits might end up in a hard-to-manage detached state.
  • To get back to your original branch, just repeat the branch checkout steps above and select your target branch.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 03:34:36