I'll echo what Charles said with the addition of using git. You can literally branch your notes just like you would source code and it plays nicely with latex. You can roll back, merge, and share with others very easily. You can tag commits with brief explanations and search those later or use a git visualizer to quickly find something.
Plus all your work is still in text files so you can still use grep and all the usual console tools.