Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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.

share|improve this question
    
Is GUI a requirement? Both of the SCM's you list have more powerful CLI versions that run underneath. –  Guvante Jul 24 '12 at 18:23
    
Yes, I would like to use GUI. –  Another Programmer Jul 24 '12 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 Jul 24 '12 at 19:31
add comment

4 Answers

up vote 1 down vote accepted

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.

share|improve this answer
add comment

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.

share|improve this answer
    
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. –  Another Programmer Jul 25 '12 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. –  throughnothing Jul 25 '12 at 20:35
add comment

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

share|improve this answer
add comment

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.

share|improve this answer
    
the question was what source control lets you search for a particular string in any version of anything in the repository. –  psr Jul 24 '12 at 18:53
    
...and all three solutions I mentioned allow you to do just that. –  Levinaris Aug 7 '12 at 14:59
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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