automatic-backup

Linux: automatic backup on save of changed file

Is there any way/SW-tool that can be used to monitor a directory for changes to files and then either back it up to a unique file or to a version control system? Reason: I'm using Code::Blocks and get carried away editing/testing/changing and occasionally (@#$%!) would want/need to revert/recover a previous bit of code. I want the backu...