I'm very new to source control management and one thing puzzles me: is it possible to search through the whole repository for a string? For example I'm tracking one file, which has 100 commits and I would like to see all the version of the file which contain "xyz" inside.

Is this possible? I'm using various GUI clients and non of them has this..? Yes, they can search trough commit messages but I want to find a version even when the commit message does not contain the string.

To put it differently, which GUI client has such a feature? I don't care about which SCM it uses - git, hg, bazaar, all are fine.

  • Is GUI a requirement? Both of the SCM's you list have more powerful CLI versions that run underneath.
    – Guvante
    Commented Jul 24, 2012 at 18:23
  • Yes, I would like to use GUI. Commented Jul 24, 2012 at 18:31
  • GUIs are typical quite restricted, search patterns easily become quite complicated, doing search from command line is often more efficient and worth learning
    – johannes
    Commented Jul 24, 2012 at 19:31

4 Answers 4


In git, that's one of the central features, called pickaxe:

git log -Stext
git log -Gregexp

That will look up revisions that add or remove matching text anywhere. You can of course combine it with path filters and revision ranges and any other options.


Very crudely, you could

git log -p -- path/to/file

Then search in there (using '/xyz') and find the commits you're looking for. There's probably a better way, but that's a quick and dirty solution that doesn't take much thinking.

Update: SourceTree from Atlassian allows you to search through mercurial and git repositories based on commit message or file changes. I think this probably does just what you want. The user interface for SourceTree is pretty complex, and I'm not a huge fan of it myself, but when you open your repo in it, you can click the search magnifying glass tab at the very top left of the window, then select search "File Changes" in the drop down to the right of the search box. Hope this helps.

  • I tried exactly SourceTree and for Mercurial there even is no option to search file changes and in git it allows me to search but results are (for lack of better words) garbage - it always shows one file no matter what I type in. Commented Jul 25, 2012 at 7:03
  • Yes, I'm not a fan of SourceTree, but in my testing it does seem to do what you want to do. I know you are looking for a gui, but did you try my command line example? git log -p -- path/to/file will open up the fill history of all modifications to that fill with the diff, and you can search in there for whatever you want. Commented Jul 25, 2012 at 20:35
  • The search tab for me was 'bottom middle' or menu View > Search View or Ctrl + 3 shortcut. Commented Jul 15, 2015 at 3:38

My preferred version control is Mercurial. There are a lot of options available for searching via a graphical interface however these are the methods I've utilized most heavily.

In a terminal, you can hg serve. Then, hop over to a browser for more of a GUI interface. The address localhost:8000 is the default url for seeing a repository that you are serving.

Alternatively, you could use a 3rd party service such as kilnhg.com. They have a great interface that integrates nicely with their bug/feature tracking software, fogbugz.com.

Lastly, you might like TortoiseHg. It's a local application that provides a GUI for your repositories.

  • the question was what source control lets you search for a particular string in any version of anything in the repository.
    – psr
    Commented Jul 24, 2012 at 18:53
  • ...and all three solutions I mentioned allow you to do just that. Commented Aug 7, 2012 at 14:59

There is hg grep which does that (see hg help grep), though I don't know if it's exposed in any GUIs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.