I'd like to have a simple, script-like backup solution to synchronize 2 local directories which provides a "fail-safe"-mechanism allowing to undo 1 commited unwanted modification of a file that got synchronized.
Let's say I have 2 local directories d1 and d2 initially containing the exact same files.
Is it possible to use a version control system to synchronize any changes from d1 to d2 like this:
1. a file f1 in d1 gets modified
2. d1 is synchronized to d2
3. f1 in d1 gets modified again
4. d1 is synchronized to d2 again
5. the initial version of f1 gets deleted in both directories, so that only the current and the second latest version of the file remain in both directories/repositories (an undo is possible and disk space is saved)
Also, this is on Linux (Arch).
Thank you in advance for your expertise!