
Ask HN: Simple tool to record file history and revert at any time - billconan
At work, I work on a huge legacy project, with millions lines of undocumented code.<p>I often have to poke around, change few lines and rely on unit tests to figure out issues.<p>sometimes, changing certain lines will cause issues, I have to revert back. But I don&#x27;t remember what I have changed since last time.<p>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.<p>and if I do create a changelist in the perforce, my new change will overwrite my old change, I can&#x27;t see its history and revert.<p>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.<p>I want to have a simple tool that provides undo&#x2F;redo&#x2F;diff between revisions on a text file I specified. it shouldn&#x27;t be as heavy as git or perforce, shouldn&#x27;t need a server.<p>I can&#x27;t find anything like that, I&#x27;m planning writing it myself. but before I do anything, I&#x27;d like to ask here just in case.<p>For example, it can be a command line tool, with the following commands:<p>mytool -record aaa.txt<p>&#x2F;home&#x2F;hhh&#x2F;aaa.txt is recorded at rev 0<p>mytool -showhistory aaa.txt<p>&#x2F;home&#x2F;hhh&#x2F;aaa.txt has 4 revisions<p>rev 1 2016&#x2F;04&#x2F;34<p>rev 2 ...<p>...<p>mytool -undo aaa.txt<p>revert &#x2F;home&#x2F;hhh&#x2F;aaa.txt to rev 3<p>mytool -redo aaa.txt<p>mytool -diff 4&#x2F;3 aaa.txt<p>(will launch an external diff tool to show the difference)<p>mytool -forget aaa.txt<p>(get rid off all histories of aaa.txt)
======
Robin_Message
Some 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.

------
atmosx
Git 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
heavy 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
I 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.

------
eicnix
JetBrains 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
thank you

------
samfisher83
Git doesn't need a server and isn't heavy. You can just commit on a local
repo.

