3 ms·
Ask HN: Simple tool to record file history and revert at any time
At work, I work on a huge legacy project, with millions lines of undocumented code.
I often have to poke around, change few lines and rely on unit tests to figure out issues.
sometimes, changing certain lines will cause issues, I have to revert back. But I don't remember what I have changed since last time.
we use both git and perforce for source code management. but the problem is, most of the changes I want to remember are my experiments, nothing serious to create a commit or changelist.
and if I do create a changelist in the perforce, my new change will overwrite my old change, I can't see its history and revert.
one solution my friend did was using perforce as the real source code management, and creating local git repository to document local change histories. but still, you need to manually commit changes.
I want to have a simple tool that provides undo/redo/diff between revisions on a text file I specified. it shouldn't be as heavy as git or perforce, shouldn't need a server.
I can't find anything like that, I'm planning writing it myself. but before I do anything, I'd like to ask here just in case.
For example, it can be a command line tool, with the following commands:
mytool -record aaa.txt
/home/hhh/aaa.txt is recorded at rev 0
mytool -showhistory aaa.txt
/home/hhh/aaa.txt has 4 revisions
rev 1 2016/04/34
rev 2 ...
...
mytool -undo aaa.txt
revert /home/hhh/aaa.txt to rev 3
mytool -redo aaa.txt
mytool -diff 4/3 aaa.txt
(will launch an external diff tool to show the difference)
mytool -forget aaa.txt
(get rid off all histories of aaa.txt)
- atmosx 10y agoGit and Hg do exactly what you want. I'm not sure I understand what heavy means in this context, how exactly is git heavy? It's a 2MB binary. $ du -sch `which git` 2,0M /opt/local/bin/git 2,0M total You don't have to push the code to a remote repository just because everybody does. An older alternative which was created to do exactly what you described is rcs[1]. [1] http://www.gnu.org/software/rcs/ http://www.gnu.org/software/rcs/
- billconan 10y agoheavy doesn't mean the size of the file. it means the feature set and complexity of using. for example, I don't want to track all files under a folder. I just want to track few individual files I specified. perhaps, I'm not a good user of git. I don't know how to do local history with git. and eventually I need to push my change to a remote repository when my experiments are done.
- atmosx 10y agoI don't think git is complex. It has a load of features for doing complicated stuff, but that's for those who need them. In any case, one could create a set of shell aliases to perform the operations needed in any way you see fit.
- billconan 10y agoyes, rcs looks like what I want http://jodypaul.com/SWE/RCSTutorial/RCSTutorial.html http://jodypaul.com/SWE/RCSTutorial/RCSTutorial.html but it is still kinda complex. I just want to provide redo/undo to any text file independent to any text editor.
- eicnix 10y agoJetBrains IDEs have a "Local History" feature which does basically what you want. - Saves files automatically and saves revisions - Allows diffs between version - Allows rollback or patches - Include event information like unit test results or git actions at each version I don't think this is available as a CLI tool but when you are using an IDE anyway this might me a solution for you.
- billconan 10y agothank you
- samfisher83 10y agoGit doesn't need a server and isn't heavy. You can just commit on a local repo.
- Robin_Message 10y agoSome filesystems (like ZFS I think) have history for files which might help. http://www.catb.org/~esr/src/ http://www.catb.org/~esr/src/ is another option; its billed as a modern RCS.