dropbox-style svn/git/mercurial?: auto-commit upon change and auto-checkout

你离开我真会死。 提交于 2019-12-19 16:18:43

问题


I'm not a professional programmer, but I do some small solo projects and I would like some versioning and syncing, but going through the process of remember to commit and checkout (on different computers) is more of a hassle than, say, keeping code in a dropbox folder that automatically uploads to the cloud upon file change. Using the current copy is completely transparent to me, but there is no versioning. (Syncing is also a pain because I often don't open my laptop for days after getting home.)

Is there a way to have a codebase automatically commit upon file change (or just every few minutes) and automatically download the latest version if I want to continue my work from another computer?

Thanks!


回答1:


It depends on what your "projects" are.

Flashbake was created after science-fiction writer Cory Doctorow wanted to automatically capture and version his writing process at regular intervals:

Every 15 minutes, Flashbake looks at any files that you ask it to check (I have it looking at all my fiction-in-progress, my todo list, my file of useful bits of information, and the completed electronic versions of my recent books), and records any changes made since the last check, annotating them with the current timezone on the system-clock, the weather in that timezone as fetched from Google, and the last three headlines with your by-line under them in your blog's RSS feed (I've been characterizing this as "Where am I, what's it like there, and what am I thinking about?"). It also records your computer's uptime. For a future version, I think it'd be fun to have the most recent three songs played by your music player. (source)

It is based on git for versioning, and cron for automatic updates (git is sufficiently space-efficient to make this tractable). You may want to look at another review. The code is here.

If you really, really want file modification detection rather than a commit every X minutes (aka. paranoid about data), you may want something based on inotify (details - note those automated commits may add up quickly !).

Yet another option (that doesn't necessarily solve the auto-commit question, so you may want to mix) is to look at running git over dropbox. This has already been discussed here on SO.




回答2:


Dropbox keeps few versions of files in history. Hardly can be called "versioning", but you can restore files to some time back in the past.

If you really can not be bothered with commiting and merging, I'd say just live with dropbox, as it is nice and automatic.

You can set up Scheduled Task (if on Windows) or Cron Job (if Linux) that will make a commit/push every 5 minutes. And pull/update every time you start your computer. But I can see a potential nightmare waiting to happen, especially on pull/update, when manual merge is required.

Also, I'd advise using Mercurial, as it is much easier to learn/deal with than git, and more advanced than svn. This will take away some pain from version-control system.




回答3:


So what I ended up doing was using btsync to sync my code bases between several computers. This creates the immediate 'auto-sync' feature I was looking for and it's completely transparent to me. (This also takes care of the problems with having bloated auto-commits as mentioned above) But a tip: don't try and sync repos across all your computers. Although this is possible, it was unnecessary to me and it's better to just sync the files, and keep a repo on one machine you can remote into to commit and push if necessary. This way you get versioning and auto-sync (or be forced to commit daily, or worry about having to commit when you need to leave your computer, or have to deal with any commit errors that come up before you close your laptop, or most of all have to rely one's fallible memory to remember to commit daily (big one for me!)).



来源:https://stackoverflow.com/questions/7060769/dropbox-style-svn-git-mercurial-auto-commit-upon-change-and-auto-checkout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!